With the Sql Data Source control's , and so forth). If you are configuring this information via the Update Query property from the Properties window, then your screen should look like the following: Select Command="SELECT [Product ID], [Product Name], [Products].[Category ID], [Category Name], [Unit Price], [Discontinued] FROM [Products] INNER JOIN [Categories] ON [Products].[Category ID] = [Categories].[Category ID] ORDER BY [Product Name]" Update Command="UPDATE [Products] SET [Product Name] = @Product Name, [Category ID] = @Category ID, [Unit Price] = @Unit Price, [Discontinued] = @Discontinued WHERE [Product ID] = @Product ID" Note that each parameter in the Update Parameters collection is a Parameter object.
Updating is not supported by data source sqldatasource1
NET 2.0 introduced a number of new Web controls designed for accessing and modifying data. NET 2.0's data source controls make it possible to retrieve, insert, update, and delete data without having to write the tedious dedata access code that was so commonplace in ASP. Previous installments of this article series have looked at returning, inserting, and deleting data using the Sql Data Source control. These controls can work in unison with the data source controls to facilitate inserting, updating, and deleting data.
These controls allow page developers to declaratively access and modify data without writing any code to perform the data access. In this article we will examine basics of using the Sql Data Source and Grid View controls to update records from a database.
When we examined inserting data and deleting data we looked at doing so both through manually-created Web Forms and through data Web controls, like the Grid View or Details View.
In the manually-created Web Forms example for inserting, for example, we added Text Boxes, Drop Down Lists, and other Web controls to collect the values for the new record.
Once they've selected this record, you need to show it's existing values in editable fields (textboxes, cehckboxes, and so on), let the user make any modifications, and then save them.
We can easily create the Web controls necessary to facilitate an editing interface and it is simple enough to use a Sql Data Source control with appropriate Update Parameters to execute the appropriate statement with values based on the Web controls' values.
Likewise, the parameter values in the Astute readers will notice the similarity between the Access Data Source and Sql Data Source controls' inserting, deleting, and updating workflows.
Regardless of what workflow is initiated, they all follow the same six steps: the firing of the appropriate pre-action event (, in the case of the updating workflow).
The screenshot below shows the Grid View when one of its record's Edit buttons has been clicked.