skip to content »

el-feel.ru

Gridview rowupdating dataset

This will cause the Grid View to enter in edit mode (see below).Note that the Employee ID column is not editable because we have marked it as Read Only.

gridview rowupdating dataset-8gridview rowupdating dataset-20gridview rowupdating dataset-54

Since we are not using data source controls we need to handle the toggling of the sort direction on our own. Add the following code in the Sorting event handler.Once you set these properties you will find that the column headers of all the columns for which you specified Sort Expression property appear as clickable link buttons.Clicking on the link buttons raise two events: Just like paging events these events follow pre and post pattern.The Sort Direction property specifies the direction of sorting i.e. This property is not of much when you are sorting the grid on your own.However, when coupled with data source controls the Grid View can toggle the sorting direction automatically for you and you can get/set the direction using this property.We need to write our own code to update the new values back to the database in the Row Updating event.

Add the following code in the Row Editing event handler: The Row Editing event handler receives an event argument of type Grid View Edit Event Args.

The Page Index Changing event handler receives an event argument of type Grid View Page Event Args.

This argument provides the new page number that the user has selected via a property called New Page Index.

The following figure shows the Grid View after implementing paging. First of all, you need to set Allow Sorting property of the Grid View to True.

Further, you need to set Sort Expression property of the Bound Fields to the name of the column on which you would like to sort the grid.

There are many articles and tutorials around that illustrate the use of Grid View control along with the new Data Source Controls.