Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Navigate betw pages in Datagrid (Paging Navigation)
Posted
Comments
SoMad 19-Nov-13 4:08am    
I am confused about these 3 (so far) Questions and Answers you have posted. Do you have a problem you need help with or is this your way of showing how to do these things?

Soren Madsen

1 solution

C#
private void Previous_Click(object sender, EventArgs e)
        {
            currentPage = currentPage - 1;
            //Check if you are already at the first page.
            if ((currentPage < 1))
            {
                MessageBox.Show("You are at the First Page!");
                currentPage = 1;
                return;
            }
            else
            {
                recNo = (pageSize
                            * (currentPage - 1));
            }
            LoadPage();
        }

        private void Next_Click(object sender, EventArgs e)
        {
            if ((pageSize == 0))
            {
                MessageBox.Show("Set the Page Size, and then click the \"Fill Grid\" button!");
                return;
            }
            currentPage = (currentPage + 1);
            if ((currentPage > PageCount))
            {
                currentPage = PageCount;
                // Check if you are already at the last page.
                if ((recNo == maxRec))
                {
                    MessageBox.Show("You are at the Last Page!");
                    return;
                }
            }
            LoadPage();
        }
Note: LoadPage() Should be Defined by yourself!!
 
Share this answer
 

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