Hi guys,

I have implemented pagination in datagridview by using example from this page http://www.codeproject.com/KB/miscctrl/Pagable_DatagridView.aspx. The pagination works well. However, when I create 2 datagridview with each using different bindingsource, and I click on next for the first datagridview, the other datagridview also automatically paginate to the next one. I guess it's the cursor problem. Could anyone kindly advice please? Thanks in advance!

Cheers,
Mark Thien

Any clue ?

>>when I create 2 datagridview with each using different bindingsource, and I click on next for the first datagridview, the other datagridview also automatically paginate to the next one.

Have you perhaps looked into the event handler(s) you are using?

It's possible that the two DGVs are somehow sharing the same event handling for the pagination in which case they would both fire off at the same time when using the navigation on either.

Check the event handlers as Lusipher mentioned, and also check they definitely aren't sharing a binding source.
I scanned over the code in the link and for the second grid to move forward a page its datasource would have to have its filter changed. The filter is only changed in this line bindingSource1.Filter = "RecordID >= " + RecordID1 + " and RecordID <= " + RecordID2; , which names the bindingsource explicitly. So, best i can tell without seeing your code, either you have changed the code in the link and introduced the problem there, or the datagridviews are sharing a bindingsource.

EDIT: The cursor has nothing to do with it. Changing the cursor just changes the mouse cursor to give the user a visual cue (eg, Cursor = Cursors.WaitCursor; lets them know that the program is working)

The code you copied uses a set of global (local to form) variables to store the page infomation for the DGV.

private string NavClicked = "";
        private string RecordID1 = "";
        private string RecordID2 = "";
        int CurrentPage = 1;

I think that this might be the root of your problem.

You will need to make sure that there is a seperate set of these variables for each DGV or they will influence each other due to being shared (which is what you are finding).

If you are able, it would be better to modify the code to take in parameters rather than operate on global (local to form) variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.