您的位置:首页 > 其它

在GridView表头显示排序方向

2007-11-06 11:45 106 查看
代码如下:

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

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: