Using GridView to Save and Retrieve Data with AJAX
(Page 1 of 4 )
In this third part of a four-part series on making your ASP.NET applications featuring AJAX save, retrieve, and change data, you'll learn more about the GridView. This article is excerpted from chapter four of
Learning ASP.NET 2.0 with AJAX: A Practical Hands-on Guide, written by Jesse Liberty, Dan Hurwitz and Brian MacDonald (O'Reilly, 2007; ISBN: 0596513976). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.
Take It for a Spin Start the application. The product database information is loaded into your GridView. When you click the Edit button, the data grid automatically enters edit mode. You’ll notice that the editable text fields change to text boxes and checkboxes, as appropriate, and the command buttons change from Edit and Delete to Update and Cancel. Make a small change to one field, as shown in Figure 4-20.
When you click the Update button for that row, the grid and the database are both updated, which you can confirm by opening the table in the database, as shown in Figure 4-21.
To open the database table, stop the application first. Then on the right side of the IDE, click the Database Explorer tab (in VWD; it is called Server Explorer in VS2005). Expand the AdventureWorks folder, and then expand the Tables folder. Scroll down until you find the Product (Production) table (in the IDE, the schema name is displayed in parenthesis after the table name—go figure), then right-click it, and select “Show Table Data.” This will show you the contents of the table from within the IDE.

Figure 4-20. When you click Edit on a row, that row enters edit mode. Any fields that can be edited change to text boxes and checkboxes.