在我的网格视图控件中,1000条记录已经存在(从数据集绑定),当我应用搜索条件时,它会显示500条记录。
现在,我想在单击Grid列名时仅排序特定的500行。
MyGrid.Datasource = ds.Tables[0].DefaultView;
MyGrid.DataBind();
注意:在应用过滤器(搜索)之前,我不想对网格进行排序。
请帮助我只对结果gridview进行排序。
答案 0 :(得分:0)
Create all the functionallity in your GridView that handles sorting by clicking on the column names OnSorting="MyGrid_Sorting"
and AllowSorting="true"
.
If sorting works correctly set AllowSorting
to false.
Now all you have to do is enable the sorting of the GridView in code behind. Preferably in the function that applies the search criteria.
private void applyFilter()
{
MyGrid.AllowSorting = true;
MyGrid.Datasource = ds.Tables[0].DefaultView;
MyGrid.DataBind();
}