Sorting a DataTable

I have a datatable called dtSchoolResults

I grab the default view of the datatable

DataView dvSchoolResults = dtSchoolResults.DefaultView;

I specifiy the column name and sort expression for the Sort propertyof the dataview.

 dvSchoolResults.Sort = “Date Created DESC”;

I convert the view to a datatable and assign it back into dtSchoolResults

 dtSchoolResults= dvSchoolResults.ToTable();


The sort expression format is : COLUMN NAME SORT ORDER

e.g.  NAME ASC

First Name ASC

Last Name DESC



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: