Gridview SortExpression with 2 fields
- by aron
Hello,
I have a GridView that get's its datasource from a complex object.
So I'm doing the Sorting & Paging in the code behind.
<asp:GridView ID="SystemsDetailList" runat="server" AllowSorting="true" AllowPaging="true"
AutoGenerateColumns="False" ShowFooter="True" OnPageIndexChanging="gridView_PageIndexChanging" OnSorting="gridView_Sorting">
For an important title column I have a SortExpression with 2 fields:
SortExpression="FunctionalAreaDisplayCode, EswbsDisplayCode"
This in the code behind:
protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
{
BindSystemList(e.SortExpression, sortOrder);
}
public string sortOrder
{
get
{
if (ViewState["sortOrder"].ToString() == "desc")
{
ViewState["sortOrder"] = "asc";
}
else
{
ViewState["sortOrder"] = "desc";
}
return ViewState["sortOrder"].ToString();
}
set
{
ViewState["sortOrder"] = value;
}
}
For some reason it will keep "FunctionalAreaDisplayCode" always sorted ASC but the EswbsDisplayCode works fine as it flips between ASC and DESC correctly.
and tips here?
thanks!