Gridview rowupdating empty

Rated 4.88/5 based on 820 customer reviews

Here, we store the value of Sort Expression property into a Veiw State variable called sortexpression. Finally, we call Bind Grid() method which will bind sorted version of the Data View with the grid.

We need to access this variable from Bind Grid() method so that our sorting will work correctly under all the circumstances. The following figure shows the Grid View after implementing sorting.

The Grid View Sort Event Args class has three important properties.

The Sort Expression property supplies the sort expression that you specified earlier for the column being sorted.

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.

The events are as described below: Row Updating - Occurs when a row's Update button is clicked, but before the Grid View control updates the row.

In order to develop a test web form create a new web site in VS. Set various properties of the Bound Fields as shown in the following table: Here, we call Bind Grid() method if the web form is being served as a result of first request.

The Bind Grid() method is our own function that we will create later on.

The Sorting event allows you to cancel the operation also.

The Sorting event handler receives an event argument of type Grid View Sort Event Args.

Leave a Reply