Intersoft WebGrid Documentation
Walkthrough: Adding pending changes to WebGrid programmatically
See Also Send comments on this topic.

Glossary Item Box

This walkthrough shows you how to create updatable WebGrid using DataTable in BatchUpdate mode (Insert Identity / AutoIncrement ID Scenario).

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 ObjectDataSource

  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. Click the SmartTag on the upper right of the WebGrid.
  11. In Choose Data Source field, choose <New data source...>.



  12. In Data Source Configuration Wizard, choose AccessDatabase and click OK.



  13. Browse and select the database in App_Data (NorthWind.mdb) and click OK.



  14. Select the table that you want to use and click Next.



  15. Configure INSERT,UPDATE, and DELETE statements by clicking Advanced Button (Please check how to configure the INSERT,UPDATE and DELETE statements for another DataSourceControl).



  16. In this step, you can view the table's database using Test Query button. Otherwise, click Finish to proceed to the next step.
  17. Finally, choose Retrieve Structure action in Connected to Data Source Control Wizard and click OK to apply all settings.



  18. Go to LayoutSettings and set AllowEdit to Yes.
  19. Drag a html button and handle button click event include the snippet codes for adding pending changes programmatically.
  20. C# Copy Code
    function Button1_onclick() 
    {        
       var grid = ISGetObject("WebGrid1");        
       var row = grid.RootTable.GetRowByKeyValue("ALFKI");        
       row.GetCells()[2].SetText("Maria", true);         
       row.AddPendingChanges();
    }
    

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.