I want code about sorting for particular column in GRID VIEW in Asp.net C#.
When I sort one column in ASC and when go for a second Column and try to sort it takes it as DESC. I want a separate ASC DESC order for each column.
I want code about sorting for particular column in GRID VIEW in Asp.net C#.
Share
For sorting
Keep the sorting state is viewstate(SortDirection and SortExpression)
You generate the correct linq expression based on the current sorting state.
Manually handle the Sorting event in the grid and use this helper I wrote to sort by SortExpression and SortDirection:
public static IQueryable SortBy(IQueryable source, string sortExpression, SortDirection direction) {
if (source == null) {
throw new ArgumentNullException(“source”);
}
}