Reputation: 125
I have a dynamically created gridview
in c# asp.net that I need sorted when you load the page. How can this be done? I am using gridview1.DataBind()
to bind.
Upvotes: 2
Views: 647
Reputation: 28652
try this
DataTable table = GetTable();
table.DefaultView.Sort = "SortCondition";
//
// Display all records in the view.
//
DataView view = table.DefaultView;
Now Bind the grid
GridView1.DataSource=view;
GirdView1.DataBind();
Upvotes: 1