gridview 排序时候显示箭头

来源:互联网 发布:充话费软件下载 编辑:程序博客网 时间:2024/05/01 20:08
//在GridView的RowCreated事件中protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.Header) //如果是表头    foreach (TableCell MyHeader in e.Row.Cells) //对每一单元格            if (MyHeader.HasControls())        if (((LinkButton)MyHeader.Controls[0]).CommandArgument == GridView1.SortExpression)        //是否为排序列          if (GridView1.SortDirection == SortDirection.Ascending) //依排序方向加入方向箭头            MyHeader.Controls.Add(new LiteralControl("↓"));          else            MyHeader.Controls.Add(new LiteralControl("↑"));}
原创粉丝点击