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 weve made to the gridSortExpression
and gridSortDirection properties.
Filtering Data
Although were not using it in the Dorknozzle project, its interesting to note
that the DataView control can filter data. Normally youd 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
Chapter 12: Advanced Data Access

Get Build Your Own ASP.NET 2.0 Web Site Using C# & VB, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.