Click here to Skip to main content
15,895,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have One DataGridView with 2 buttons Prev and Next.Here in my DataGridView I am using Paging Concept.I have 3 labels to show window no.(1,2..),records count(each page has 5 records only)and showing from to to.In the 1st page I am getting from to to(1-5) value when I click next page the result should as 6-10 and the 3rd page should show as 11-15.I didn't get the 2nd page result as shown above.
(Here my Database consists of 15 records in the Table)
Thanks in advance.
Posted
Comments
Maciej Los 27-Aug-15 1:49am    
What have you tried? Where are you stuck? What's your database?
Kanaparthi Sureshma Reddy 27-Aug-15 2:07am    
This is my code in btnNext_Click event.
int nextCount = minValue + maxValue;
dt = new DataTable();
da.Fill(nextCount, maxValue, dt);
GridAddressBook.DataSource = dt;
lblShowResults.Text = GridAddressBook.RowCount.ToString();
int windowshow = int.Parse(lblShowResults.Text);
if (windowshow <= 5)
{

int nextpage = Convert.ToInt32(lblWindowShow.Text) + 1;
lblWindowShow.Text = Convert.ToString(nextpage);
//lblWindowShow.Text = "2";
}
else if (windowshow <= 5)
{
lblWindowShow.Text = (objD.NoOfRecords() / 10).ToString();
}
lblShowingShow.Text = lblWindowShow.Text + "-" + lblShowResults.Text;
minValue = nextCount;
if (dt.Rows.Count == maxValue)
{
btnPrev.Enabled = true;
btnNext.Enabled = true;
}
else
{
btnPrev.Enabled = true;
btnNext.Enabled = false;
minValue = nextCount + dt.Rows.Count;
}
btnPrev.Enabled = true;
where lblShowResults=RecordCount in DataGrid,lblWindowShow=Window/Page Number and lblShowingShow=Showing results from 1-5,6-10...

1 solution

Google[^] is your friend! Use it.

CodeProject KnowledgeBase returns, for example:
Paging DataGridView in C# using LINQ[^]
A Simple Way for Paging in DataGridView in WinForm Applications[^]
 
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