DataGrid - Paging problem

C

Calvin KD

I have a simple datagrid with bound columns. My problem is: Everytime I click
the ellipsis (the ...) at the end of the page numbers (custom paging) to go
to the next set of pages, when the next set of pages is displayed :
1. The next sequential page number (first page of the next set) is shown
without the underline, but the grid contents are not the contents of the
indicated page number. The contents apparently belong to the last page of
that new set. But I could not click on the first page because it has no
underline (currently active).
2. When I click on any other page numbers, it somehow takes me back to the
first set of pages.

Following is the sample of my Grid_Changed() event codes activated from the
onpageindexchanged event:
public void dgResults_Changed(object sender, DataGridPageChangedEventArgs e)
{
dgResults.CurrentPageIndex = e.NewPageIndex;
Display_Results();
}
private void Display_Results()
{
...
SqlDataAdapter daCOT = new SqlDataAdapter(sSQL, objDBConn);
daCOT.Fill(dstCOT);
if (dstCOT != null)
{
if (dstCOT.Tables[0].Rows.Count > 0)
{
grResults.PagerStyle.Visible = true;
}
else
{
// No records returned, so hide the Pager row.
grResults.PagerStyle.Visible = false;
}
}
...
}

Any ideas anyone?
Thanks
 
K

Kostadin Kostov

Apparently your code doesn't do what it should. I suggest checking if the
"dgResults_Changed" event handler handles the OnPageIndexChenged event. Put a
breakpoint on the first line of the dgResults_Changed function, attach the
debugger to the process and see if it hits the breakpoint.
 
C

Calvin KD

Thanks Kostadin. I did put a breakpoint and traced it and it did get there.
The strange problem was e.NewPageIndex returned the wrong value. My pagesize
is 10, after I clicked the ellipsis to go to the next set of pages then
clicked 12, it returned 2. I've tried others and the strange pattern seemed
to emerge that it returned the number on the previous page that has the same
position as the one that I clicked: Clicked 11, it returned 1; clicked 19,
returned 9 etc.... very strange. I don't know what has caused this strange
bug and I hope someone out there may have experienced and resolved the same
problem.

Kostadin Kostov said:
Apparently your code doesn't do what it should. I suggest checking if the
"dgResults_Changed" event handler handles the OnPageIndexChenged event. Put a
breakpoint on the first line of the dgResults_Changed function, attach the
debugger to the process and see if it hits the breakpoint.

Calvin KD said:
I have a simple datagrid with bound columns. My problem is: Everytime I click
the ellipsis (the ...) at the end of the page numbers (custom paging) to go
to the next set of pages, when the next set of pages is displayed :
1. The next sequential page number (first page of the next set) is shown
without the underline, but the grid contents are not the contents of the
indicated page number. The contents apparently belong to the last page of
that new set. But I could not click on the first page because it has no
underline (currently active).
2. When I click on any other page numbers, it somehow takes me back to the
first set of pages.

Following is the sample of my Grid_Changed() event codes activated from the
onpageindexchanged event:
public void dgResults_Changed(object sender, DataGridPageChangedEventArgs e)
{
dgResults.CurrentPageIndex = e.NewPageIndex;
Display_Results();
}
private void Display_Results()
{
...
SqlDataAdapter daCOT = new SqlDataAdapter(sSQL, objDBConn);
daCOT.Fill(dstCOT);
if (dstCOT != null)
{
if (dstCOT.Tables[0].Rows.Count > 0)
{
grResults.PagerStyle.Visible = true;
}
else
{
// No records returned, so hide the Pager row.
grResults.PagerStyle.Visible = false;
}
}
...
}

Any ideas anyone?
Thanks
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top