能把你点击标题排序的代码发给我吗?
1个回答
展开全部
先把allowsorting属性设置为true,写gridview的sroting方法。
protected void record_dgv_Sorting(object sender, GridViewSortEventArgs e)
{
string sql = "";
if (ViewState["SortDirection"] == null || ViewState["SortDirection"].ToString().CompareTo("") == 0)
{
ViewState["SortDirection"] = " asc";
}
else if (ViewState["SortDirection"].Equals(" desc"))
{
ViewState["SortDirection"] = " asc";
}
else if (ViewState["SortDirection"].Equals(" asc"))
{
ViewState["SortDirection"] = " desc";
}
sql = " order by " + e.SortExpression + ViewState["SortDirection"];
GetDataSet(sql); //获取数据的方法,重新加载一遍,把sql参数加到获取数据sql后边
}
protected void record_dgv_Sorting(object sender, GridViewSortEventArgs e)
{
string sql = "";
if (ViewState["SortDirection"] == null || ViewState["SortDirection"].ToString().CompareTo("") == 0)
{
ViewState["SortDirection"] = " asc";
}
else if (ViewState["SortDirection"].Equals(" desc"))
{
ViewState["SortDirection"] = " asc";
}
else if (ViewState["SortDirection"].Equals(" asc"))
{
ViewState["SortDirection"] = " desc";
}
sql = " order by " + e.SortExpression + ViewState["SortDirection"];
GetDataSet(sql); //获取数据的方法,重新加载一遍,把sql参数加到获取数据sql后边
}
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询