我有2个功能。在一个函数中,我有2个viewstate值来获取方向 和排序顺序。现在我想在另一个函数中使用它。
我试过这样:
Session["a"] = Viewstate["a"];
Session["b"] = Viewstate["b"];
但它返回NULL值:
private string SortDirection(string column)
{
string sortDirection = WebConstants.SortDirection.Ascending.ToString();
string sortExpression = ViewState["SortExpression"] as string;
if (sortExpression != null)
{
if (sortExpression == column)
{
string lastDirection = ViewState["SortDirection"] as string;
if ((lastDirection != null) && (lastDirection == WebConstants.SortDirection.Ascending.ToString()))
{
sortDirection = WebConstants.SortDirection.Descending.ToString();
}
}
}
ViewState["SortDirection"] = sortDirection;
ViewState["SortExpression"] = column;
return sortDirection;
}
我做错了什么?