Wrox Programmer Forums
|
BOOK: Professional ASP.NET 1.0, Special Edition/1.1
This is the forum to discuss the Wrox book Professional ASP.NET 1.1 by Alex Homer, Dave Sussman, Rob Howard, Brian Francis, Karli Watson, Richard Anderson; ISBN: 9780764558900
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 1.0, Special Edition/1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 25th, 2005, 01:06 PM
Registered User
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default a problem RowChanging and RowChanged

in chapter 9,the book said the event of rowchanging occurred before using acceptchanges,the event of rowchanged occurred after using acceptchanges.but in the example(update-check-errors.aspx):
Code:
objDataSet.AcceptChanges();

    // now set up event handler to react to changes to the rows in the table
    DataTable objTable = objDataSet.Tables["Books"];
    objTable.RowChanged += new DataRowChangeEventHandler(OnRowChanged);

    // now change some records in the Books table
    objTable.Rows[0]["Title"] = "Amateur Theatricals for Windows 2000";
    objTable.Rows[2]["PublicationDate"] = new DateTime(2001, 2, 11);

    // declare a variable to hold a DataView object
    DataView objDataView;

    // get DataView and set to show only modified rows
    objDataView = objDataSet.Tables[0].DefaultView;
    objDataView.RowStateFilter = (DataViewRowState)DataRowState.Modified;

    // display the contents of the modified rows
    dgrResult.DataSource = objDataView;
    dgrResult.DataBind();
    ....
    void OnRowChanged(Object objSender, DataRowChangeEventArgs objArgs)
in the above,after changing the datatable,we didn't use acceptchanges,but the event of OnRowChanged occurred after using acceptchanges.
In my opinion,the correct code should be:
Code:
objDataSet.AcceptChanges();

    // now set up event handler to react to changes to the rows in the table
    DataTable objTable = objDataSet.Tables["Books"];
    objTable.RowChanged += new DataRowChangeEventHandler(OnRowChanged);

    // now change some records in the Books table
    objTable.Rows[0]["Title"] = "Amateur Theatricals for Windows 2000";
    objTable.Rows[2]["PublicationDate"] = new DateTime(2001, 2, 11);
    objTable.acceptchanges()//this must be needed
    // declare a variable to hold a DataView object
    DataView objDataView;

    // get DataView and set to show only modified rows
    objDataView = objDataSet.Tables[0].DefaultView;
    objDataView.RowStateFilter = (DataViewRowState)DataRowState.unchanged;

    // display the contents of the modified rows
    dgrResult.DataSource = objDataView;
    dgrResult.DataBind();
    ....
    void OnRowChanged(Object objSender, DataRowChangeEventArgs objArgs)
 poor EngLish,sorry!

 
Old March 25th, 2005, 01:25 PM
Registered User
 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I used the book of professional asp.net 1.1 .










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.