楼座号 房间号 收费方式 缴费状态
这4列,我想实现的就是先按楼座号排序,不管是降还是升,然后点房间号,再在原来的基础上排序,后面的2列也同前面的,就是所有的排序都是在原来的基础上实现排序,
我的代码:
protected void gv_Sorting(object sender, GridViewSortEventArgs e)
{
string sort = e.SortExpression;
DataView dv = ((DataSet)Session[ "ds "]).Tables[0].DefaultView;
if (ViewState[ "direction "] == null)
{
ViewState[ "direction "] = "desc ";
ViewState[ "sort "] = sort + " desc ";
dv.Sort = ViewState[ "sort "].ToString();
}
else
{
if (ViewState[ "direction "].ToString() == "asc ")
{
ViewState[ "sort "] += ", " + sort+ " desc ";
dv.Sort = ViewState[ "sort "].ToString();
ViewState[ "direction "] = "desc ";
}
else
{
ViewState[ "sort "] += ", " + sort + " asc ";
dv.Sort = ViewState[ "sort "].ToString();
ViewState[ "direction "] = "asc ";