ComponentOne GridView for ASP.NET AJAX: GridView for ASP.NET AJAX Task-Based Help > Binding the Grid to a Data Source > Automatically Updating the Data Source

Automatically Updating the Data Source

This topic illustrates how to create an editable grid using templates and a DataSource control. Complete the following steps:

1.   Create a grid and bind it to a DataSource control; see Binding the Grid to a Data Source topic for details. Use the Suppliers table in the Northwind database and retrieve the SupplierID, CompanyName, ContactName, and Address fields.

2.   Configure UpdateQuery:

a.   Right-click the AccessDataSource1 component and then click Properties. In the Properties tab click the ellipsis button next to UpdateQuery. The Command and Parameter Editor dialog box appears.

b.   Click Query Builder, select the Suppliers table and click Add.

c.    Insert the following text in UPDATE command and click OK to close the Query Builder:

UPDATE Suppliers SET CompanyName = ?, ContactName = ?, Address = ? WHERE (SupplierID = ?)

d.   Click the Add Parameter button and rename the parameter "SupplierID".

e.   Click Show advanced properties and set the Type property to Int32

f.    In the same way, add CompanyName, ContactName, Address parameters, but set their Types to String.

g.   Click OK to close the Command and Parameter Editor dialog box.

3.   Right-click the C1GridView control and then click Show Smart Tag.

4.   On the C1GridView Tasks menu, in the Choose Data Source box, click AccessDataSource1, if necessary.

5.   Right-click the C1GridView control and click Properties. In the Properties window set the DataKeyNames value to SupplierID.

* Sample Project Available

For the complete sample, see the SimpleEdit sample located on the ComponentOne HelpCentral Sample page.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.