protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
lblResult.Text = "";
string x = (string)ViewState["direction"];
if (x == null)
{
e.SortDirection = SortDirection.Descending;
e.SortExpression = e.SortExpression;
ViewState.Add("direction", "Asc");
ViewState.Add("columnname", e.SortExpression);
ViewState["direction"] = "Desc";
}
if (x == "Desc")
{
e.SortDirection = SortDirection.Descending;
e.SortExpression = e.SortExpression;
ViewState.Add("columnname", e.SortExpression);
ViewState["direction"] = "Asc";
}
if (x == "Asc")
{
e.SortDirection = SortDirection.Ascending;
e.SortExpression = e.SortExpression;
ViewState.Add("columnname", e.SortExpression);
ViewState["direction"] = "Desc";
}
bindgridview(); -- ur function to bind gridview..
}
Enter your message below
Sign in or Join us (it's free).