Wilson Kao
Wilson Kao

Reputation: 131

Sorting a datagrid on unbounded data ASP.net

so i know that there are built in datagrid functions to sort for bounded items. However, my datagrid is bound dynamically and I am wondering how I can get this sort function to work. I know I should be coding inside the Sorting event, and probably would have to use some ADO.net since that is what I am working with. Im not sure if any code would help but if you need any please ask. I just want to know which functions (if vs2010 has one) should I use to get column names and such. Thanks!

Upvotes: 1

Views: 299

Answers (1)

James Johnson
James Johnson

Reputation: 46067

You can try sorting the DataTable, like so:

DataTable1.DefaultView.Sort = "SomeColumn ASC";

DataGrid1.DataSource = DataTable1.DefaultView.ToTable();
DataGrid1.DataBind();

Upvotes: 1

Related Questions