如何在gridview的排序列旁边加一个图片?
在gridview1里面有两列排序列,UserID和Dept,一点列名就会改变排序方式,我想在列名旁加上个图标,比如UserID升序时就是向上的箭头,降序时就变成是向下的箭头。
该如何实现?
以下是我实现排序的代码:
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression.ToString();
string sortDirection = "ASC";
if (sortExpression == this.GridView1.Attributes["SortExpression"])
{
sortDirection = (this.GridView1.Attributes["SortDirection"].ToString() == sortDirection ? "DESC" : "ASC");
}
this.GridView1.Attributes["SortExpression"] = sortExpression;
this.GridView1.Attributes["SortDirection"] = sortDirection;
this.BindGridView();
}
前台代码:
<Columns>
<asp:BoundField DataField="USERID" HeaderText="工号" SortExpression="USERID">
<ControlStyle Width="60px" />
<ItemStyle HorizontalAlign="Center" Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="Dept" HeaderText="部门" SortExpression="Dept">
<ControlStyle Width="60px" />
<ItemStyle HorizontalAlign="Center" Width="80px" />
</asp:BoundField>
</Columns>