Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng]-1.pdf
Скачиваний:
142
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

Chapter 12: Advanced Data Access

else

{

gridSortDirection = SortDirection.Ascending;

}

}

else

{

gridSortDirection = SortDirection.Ascending;

}

Finally, we save the new sort expression to the gridSortExpression property, whose value will be retained in case the user keeps working (and changing sort modes) on the page:

Visual Basic

File: Departments.aspx.vb (excerpt)

'Save the new sort expression gridSortExpression = sortExpression

'Rebind the grid to its data source BindGrid()

C#

File: Departments.aspx.cs (excerpt)

//Save the new sort expression gridSortExpression = sortExpression;

//Rebind the grid to its data source BindGrid();

After we store the sort expression, we rebind the grid to its data source so that the expression will reflect the changes we’ve made to the gridSortExpression and gridSortDirection properties.

Filtering Data

Although we’re not using it in the Dorknozzle project, it’s interesting to note that the DataView control can filter data. Normally you’d have to apply WHERE clauses to filter the data before it reaches your application, but in certain cases you may prefer to filter data on the client.

Imagine that you wanted to display employees or departments whose names started with a certain letter. You could retrieve the complete list of employees or departments from the database using a single request, then let the user filter the list locally.

520