1

I got here a answer to sort the gridview.
sorting and paging with gridview asp.net
But using the above solution all the grid data sorted while clicking on the any column.
I request a solution which sorts data on the particular page only. Suppose I have 10 pages with 50 records each page, now if I visit page 7 and sort then the only 50 records of the page 7 should be sorted.

Community
  • 1
  • 1
sam
  • 685
  • 7
  • 17

1 Answers1

0

If it just matters for the current page, avoid the hassle and use a Javascript solution.

You can also do it in ASP.NET. Grab the data you want from your DataSet, after paging (so records 350 to 400 for page 7), then change your binding from something like:

// do this
gv.DataSource = pagedDataSet.OrderBy(d => d.NameOfField);

// instead of
gv.DataSource = pagedDataSet;

If you have dynamic columns, or don't want to do write this for every possible property; see my solution in this answer.

Community
  • 1
  • 1
Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120