Intersoft WebGrid Documentation
Walkthrough: Configuring Updatable WebGrid in Batch Update mode (Using DataSet Binding)
See Also Send comments on this topic.

Glossary Item Box

This walkthrough shows you how to configure updatable WebGrid bound to DataSet.

During this walkthrough, you will learn how to do the following:

 Prerequisites

In order to complete this walkthrough, you will need the following:

  • Access to the Microsoft Access Northwind database.
  • Visual Studio 2008 Application.

 Step-By-Step Instructions

To create new web application and bind WebGrid to AccessDataSource

  1. Launch Visual Studio.NET 2008.
  2. Click on File menu, then select New and click Web Site.
  3. Select ASP.NET Web Site in the Template box and set Location to HTTP.
  4. Named the Web Site and click OK.
  5. Right-click on Project's name and select Add New Item.
  6. Select Intersoft AppForm in the My Templates box and named it as Walkthrough.aspx.
  7. Drag WebGrid instance from ToolBar to WebForm.
  8. In the Solution Explorer, right-click on App_Data and select Add Existing Item.
  9. Browse and add NorthWind.mdb in C:\Program Files\Intersoft Solutions\Data (Default installation folder).
  10. In the Solution Explorer, Add App_Code folder on your project and create new DataSet that connect to NorthWind.mdb in that folder.
  11. Click the SmartTag on the upper right of the WebGrid.
  12. Select Allow Add New, Allow Editing, and Allow Delete properties.



  13. Set AllowBatchUpdate to True on WebGrid Layout Settings.



  14. Add InitializeDataSource, PrepareDataBinding, and BatchUpdate events from toolbar properties:



  15. On InitializeDataSource event add these codes to bind WebGrid into Dataset:
    C# Copy ImageCopy Code
    protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
    {     
       DsNorthwind.CustomersDataTable dt = new DsNorthwind.CustomersDataTable();     
       DsNorthwindTableAdapters.CustomersTableAdapter da = new DsNorthwindTableAdapters.CustomersTableAdapter();
       da.Fill(dt);     
       e.DataSource = dt;
    }
    

  16. On PrepareDataBinding event add these codes to retrieve WebGrid structure:
    C# Copy ImageCopy Code
    protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
    {      
       if (!IsPostBack)          
          WebGrid1.RetrieveStructure();
    }
    

  17. BatchUpdate event add these codes to update all changes that user made during batch update:
    C# Copy ImageCopy Code
    protected void WebGrid1_BatchUpdate(object sender, ISNet.WebUI.WebGrid.BatchUpdateEventArgs e)    
    {        
       DsNorthwindTableAdapters.CustomersTableAdapter da = new DsNorthwindTableAdapters.CustomersTableAdapter();        
       DsNorthwind.CustomersDataTable dtCust = (DsNorthwind.CustomersDataTable)WebGrid1.GetCachedDataSource();        
       DsNorthwind.CustomersDataTable changeDT = (DsNorthwind.CustomersDataTable)dtCust.GetChanges();        
       da.Update(changeDT);    
    }
    

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.