Updating database using gridview

Rated 4.84/5 based on 546 customer reviews

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.

If the Cancel button is clicked, the row reverts to its pre-editing interface and any changes are not saved.

If the Update button is clicked, the Sql Data Source's updating workflow begins, thereby updating the database with the user's changes.

This article is one in a series of articles on ASP. In particular, we look at enabling editing support in the Grid View. This article focuses on the Sql Data Source control; for a detailed look at updating with the Object Data Source, refer to the "Editing, Inserting, and Deleting" tutorials in my Working with Data in ASP. Let's explore the updating "action" for the Access Data Source and Sql Data Source controls in more detail.

NET 2.0 introduces three new data Web controls: the Grid View, the Details View, and the Form View.

Updating data through manually-created Web Forms is a bit more difficult and less practical because the Web controls that make up the updating interface must also be populated with the values of the record being edited.

For example, to let a visitor edit a database record you first need to let them choose which record to edit.

To illustrate the Grid View's editing capabilities, let's step through the editing process from the end user's perspective.AND Primary Key Column Name N = @Primary Key Value To Update N , in this instance - has its value specified via the data source control's Select Parameters, which can specify a source for the parameter value.The source may be: a hard-coded value like "3.95", which would return all products less than .95; the value of a Web control on the page, allowing the user to enter a price bound in a Text Box; from the querystring; from session state; and so on.In particular, Bound Fields turn into Text Box Web controls; Check Box Fields, which are displayed as unclickable checkboxes in the read-only status, become clickable.This interface allows the user to make changes to the selected row's values.

Leave a Reply