代码如下:

//在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("↑"));

}

相关文章:

  • 2021-08-12
  • 2021-07-22
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
猜你喜欢
  • 2022-12-23
  • 2021-10-24
  • 2022-01-20
  • 2021-10-22
  • 2022-12-23
  • 2021-06-16
  • 2022-01-11
相关资源
相似解决方案