但是点击还是不能排序,见鬼了,哪位帮忙,哪出问题了.html写法:
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="username" HeaderText="用户名" SortExpression="username" />
<asp:BoundField DataField="userkind" HeaderText="部门" SortExpression="userkind" />
<asp:BoundField DataField="wenti" HeaderText="问题" SortExpression="wenti" />
<asp:BoundField DataField="wentilist" HeaderText="问题2" SortExpression="wentilist" />
aspx.cs代码事件如下:
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
ViewState["sortexpression"] = e.SortExpression;
if (ViewState["sortdirection"] == null)
{
ViewState["sortdirection"] = "asc";
}
else
{
if (ViewState["sortdirection"].ToString() == "asc")
{
ViewState["sortdirection"] = "desc";
}
else
{
ViewState["sortdirection"] = "asc";
}
}
Bindgridview();
}