skip to content »

doktorzelen.ru

Get boundfield value in rowupdating

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.

get boundfield value in rowupdating-47get boundfield value in rowupdating-68get boundfield value in rowupdating-54

The Page Index Changing event handler receives an event argument of type Grid View Page Event Args.By default this field renders a link button titled Edit.Once we click on edit the Grid View raises an event called Row Editing and the Edit link button changes to Update and Cancel link buttons.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.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.The Data View supplies all the records from the Employees table.

In order to implement paging you need to set Allow Paging property of the Grid View control to True. There are two events of Grid View that are related to paging.

This calls for some extra coding from developer's end. As an example we are going to use Employees table of the Northwind database. Add three Bound Fields and a Command Field to the Grid View with the help of Fields dialog (see below).

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 Sort Expression property supplies the sort expression that you specified earlier for the column being sorted.

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.

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