Gridview updating database

This example shows how to edit and update records in a Grid View in ASP. This example is helpful in situations where an administrator needs to edit several records from the database.For demonstration I have created a database (named Database.mdf) in which we have a table named tbl_Employee. I encourage you to still read this article to get an overview of the rationale behind the custom Grid View control and to understand the initial architecture. NET 2.0, the Grid View control serves as a much more functional and feature-rich choice. This article's text has not been updated to reflect these changes.After you've finished this article, read Improving the Sort Arrows Grid View Control, which discusses the enhancements in more detail. NET version 2.0 was released, I wrote a book and dozens of articles on the Data Grid control, which was the most functional data Web control in the ASP. The Grid View can be bound to data source controls like the Sql Data Source and Object Data Source, and paging, sorting, editing, and deleting can be implemented without having to write a single line of code.While the Data Grid (and Grid View) offer built-in sorting support, there is no visual feedback as to what column the data is sorted by.In Part 18 of the An Extensive Examination of the Data Grid Web Control article series, I showed how to dynamically update a sortable Data Grid's header columns so that an up or down arrow image would appear next to the sorted column name depending on whether the column was sorted ascendingly or descendingly (view a live demo).This was accomplished by programmatically looping through the Data Grid's I recently needed to implement this functionality in a Grid View control. NET page, like I did with the Data Grid demo, I decided to instead create a custom Web server control that extended the Grid View control, adding the necessary functionality. If the Grid View is bound to a data source control that supports sorting, the Grid View will internally re-bind to the data source using the new sort order.

This functionality enables the Grid View control to provide built-in, bi-directional sorting.

The following diagram depicts the sorting workflow, including the Grid View's assignment of its properties.

Keep in mind that the entire process is kicked off by the user clicking a Link Button in one of the sortable column's headers, and completes by displaying the data in the requested sorted order.

So, from the end user's perspective, she clicks the text in a particular column header and the data is sorted by that column.

For more information on sorting with the Grid View, along with a downloadable demo, check out the Paging and Sorting Report Data tutorial.

When I implemented the up and down arrow images for the Data Grid control in Part 18 of the An Extensive Examination of the Data Grid Web Control article series, I put the code that added (or removed) the arrow images in the ASP. Specifically, the code enumerated the Data Grid's properties.

Please or register to post comments
If spammers comment on your content, only you can see and manage such comments Delete all

Gridview updating database introduction

Gridview updating database