Click here to Skip to main content
15,896,469 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Set First allowSorting True



protected void grvDebtor_Sorting(object sender, GridViewSortEventArgs e)
{

DataTable dataTable = Session["data"] as DataTable;

if (dataTable != null)
{
DataView dvSortedView = new DataView(dataTable);

dvSortedView.Sort = e.SortExpression + " " + getSortDirectionString(e.SortDirection,e.SortExpression);
hdnsortedval.Value = e.SortExpression;
grvDebtor.DataSource = dvSortedView;
grvDebtor.DataBind();
}
}


private string getSortDirectionString(SortDirection sortDirection, string SortExpression )
{
string newSortDirection= String.Empty;

if (hdnsortedval.Value.Equals(SortExpression))
{

newSortDirection = "DESC";

}
else
{
newSortDirection = "ASC";
}
return newSortDirection;
}
Posted
Comments
RelicV 20-May-13 7:44am    
What am I supposed to do here..? find out the error in your brain..?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900