我在c#asp.net中有一个动态创建的gridview
,我需要在加载页面时对其进行排序。如何才能做到这一点?我使用gridview1.DataBind()
绑定。
答案 0 :(得分:1)
试试这个
DataTable table = GetTable();
table.DefaultView.Sort = "SortCondition";
//
// Display all records in the view.
//
DataView view = table.DefaultView;
现在绑定网格
GridView1.DataSource=view;
GirdView1.DataBind();