Problem with Sorting AND Paging in a GridView

G

gnewsgroup

I have a GridView, with sorting and paging enabled.

The GridView is bound in code-behind, where I also have the sorting
and paging event handlers.

Both sorting and paging seem to be working fine, but the problem is,
if I click on a page index, the sorting order is reversed. To make it
clear, suppose my GridView has 4 pages like below:

Page 1:

A
B
C

Page 2:

D
E
F

Page3:

G
H
I

Page 4:

J
K
L

If I click on the table header, the data gets sorted, fine, like so:

Page 1:

L
K
J

But, if I then click on the page index 2, I see this:

Page 2:

D
E
F

Whereas, I am expecting to see this:

Page 2:

I
H
G

See the problem? How to overcome this? Thanks.
 
P

Peter Bromberg [C# MVP]

store the current sort order in ViewState, then pull it back out and set the
sort just before rebinding the Grid on a new page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top