Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Building Data Access Components with ADO.NET FIGURE 19.16 Tracking data row changes. LISTING 19.31 ShowMovie9.aspx protected void btnReject_Click(object sender, EventArgs e) { Movie9 movie = new Movie9(); movie.RejectChanges(); grdMovies.DataBind(); } protected void btnAccept_Click(object sender, EventArgs e) { Movie9 movie = new Movie9(); movie.AcceptChanges(); grdMovies.DataBind(); } From the Library of Wow! eBook Disconnected Data Access 905 Show Movie9 Edit Movies | 904 CHAPTER 19 Building Data Access Components with ADO.NET FIGURE 19.16 Tracking data row changes. LISTING 19.31 ShowMovie9.aspx @ Page Language C @ Import Namespace System.Data DOCTYPE html PUBLIC - W3C DTD XHTML 1.0 Transitional EN http www.w3.org TR xhtml1 DTD xhtml1-transitional.dtd script runat server protected void btnReject_Click object sender EventArgs e Movie9 movie new Movie9 movie.RejectChanges grdMovies.DataBind protected void btnAccept_Click object sender EventArgs e Movie9 movie new Movie9 movie.AcceptChanges grdMovies.DataBind script html xmlns http www.w3.org 1999 xhtml From the Library of Wow eBook Disconnected Data Access 905 head id Head1 runat server title Show Movie9 title head body form id form1 runat server div h1 Edit Movies h1 asp GridView id grdMovies DataSourceID srcMovies DataKeyNames Id AutoGenerateEditButton true Runat server Columns asp TemplateField ItemTemplate DataRowView Container.DataItem .Row.RowState ItemTemplate asp TemplateField Columns asp GridView br asp Button id btnReject Text Reject Changes OnClick btnReject_Click Runat server asp Button id btnAccept Text Accept Changes OnClick btnAccept_Click Runat server 19 asp ObjectDataSource id srcMovies TypeName Movie9 SelectMethod GetAll UpdateMethod Update Runat server div From the Library of Wow eBook 906 CHAPTER 19 Building Data Access Components with ADO.NET form body html If you click the Accept Changes button all the changes made to the rows in the GridView are sent to the database. If you click the Reject Changes button all the rows revert to their original values. Using the DataView Object The DataView object represents an in-memory database view. You can use a DataView object to create a sortable filterable view of a DataTable. The DataView object supports three important properties Sort Enables you to sort the rows represented by the DataView. RowFilter Enables you to filter the rows represented by the DataView. RowStateFilter Enables you to filter the rows represented