实现功能:单击Gidview列名按该列升序或降序排列,且在排序列上显示向上来向下箭头示意图片
//设置Gridview的AllowSorting属性值为true,即允许排序
AllowSorting="True" OnSorting="gridview1_Sorting" OnRowCreated="gridview1_RowCreated" >
//为要排序的列加上SortExpression属性,其值为绑定的字段,如:
SortExpression="ID">
//添加Sorting和RowCreated事件
OnSorting="gridview1_Sorting" OnRowCreated="gridview1_RowCreated" >
后台代码,创建如下方法:
//设置默认表达式和排序顺序,放到page_load事件中
public void SetSorting()
{