O'Reilly logo

ASP.NET Developer's JumpStart by Ken Getz, Paul D. Sheriff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sorting Columns

It would be nice if your table could sort its data when you click a column within the table. It would be even better if the data could toggle between sorting in ascending order and sorting in descending order when you click the column header multiple times. You can accomplish this goal, but you'll need to write some code to make it happen.

No sorting can occur in the DataGrid control unless you handle two issues:

  • The control's AllowSorting property must be set to True.

  • Each column for which you want to allow sorting must have its SortExpression property set to reflect the expression you'd like to use for sorting when that column is selected.

You handled both of these issues when you created the DataGrid control earlier in the chapter. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required