Posted on: 10/12/2015 2:45:04 PM | Views : 1010

I have a gridview which im trying to sort. When the user clicks the heading for the column the following events/code lines are hit/executed:
Bind the data
void BindGrid() { if (this.ViewState["OrderBy"] == "Col1") { if (this.ViewState["Col1SortOrder"] == "DESC") { gv1.DataSource = GetDataList.OrderByDescending(s => s.StartDate); } else { gv1.DataSource = GetDataList.OrderBy(s => s.StartDate); } } else if (this.ViewState["OrderBy"] == "Col2") { if (this.ViewState["Col2SortOrder"] == "DESC") { gv1.DataSource = GetDataList.OrderByDescending(s => s.Col2); } else { gv1.DataSource = GetDataList.OrderBy(s => s.Col2); } } }
Sorting

 Go to the complete details ...