|
|
|
start date: Sun, 17 Jun 2007 10:48:31 GMT,
posted on: microsoft.public.dotnet.framework.aspnet.datagridcontrol
back
| Thread Index |
|
1
Jason Teagle
|
|
2
Scott M. am
|
Paging
I'm rather confused / frustrated with paging. It seems impossible.
I have a database with X rows in a table, and I want to present a grid that
shows a paged view of just 10 items, and let the user navigate through he
entire table 10 items at a time. Simple enough, right?
If I set AllowPaging to True, either by the grid's design-time properties or
through code during Page_Load(), but NOT AllowCustomPaging, the grid shows
nothing - no records - at run time (and PageCount is 0). Why?
The grid has been bound to the SQL query from that table (if I switch paging
off, this is confirmed by seeing all records), so the data is there - but it
won't show anything.
If I set AllowCustomPaging to True, I get *slightly* better results; it will
display items from the first page. However, it still isn't working right. If
I call DataBind() during PageIndexChanged(), it stops displaying anything
after the first click on a number, even if I go back to page 1; if I take
that DataBind() line out, it always displays the first page only, AND I have
to click each number twice to make it show the other page number as
selected.
According to what I read, custom paging should be done if you can make
queries that only contain that pageful; this is not what I want - if I could
make such queries then I wouldn't need the paging facility, I could
implement paging myself with an URL parameter to say which page index.
This is why I wanted paging without custom paging - I want to supply the
query that returns ALL records from the table, and have the grid control
page through them. So the first option is the right one, but I don't
understand why it refuses to show any records.
Help?
--
Jason Teagle
jason@teagster.co.uk
Date:Sun, 17 Jun 2007 10:48:31 GMT
Author:
|
Re: Paging
When you use paging, you must not DataBind during Page_Load in postback
situations. Instead, in PostBack situations, do the DataBind as the last
command of the PageIndexChanged event and in that event handler, you'll need
to set the grid's currentPageIndex property to e.item.currentpageindex
"Jason Teagle" wrote in message
news:3k8di.189$H61.13@newsfe4-win.ntli.net...
> I'm rather confused / frustrated with paging. It seems impossible.
>
> I have a database with X rows in a table, and I want to present a grid
> that shows a paged view of just 10 items, and let the user navigate
> through he entire table 10 items at a time. Simple enough, right?
>
> If I set AllowPaging to True, either by the grid's design-time properties
> or through code during Page_Load(), but NOT AllowCustomPaging, the grid
> shows nothing - no records - at run time (and PageCount is 0). Why?
>
> The grid has been bound to the SQL query from that table (if I switch
> paging off, this is confirmed by seeing all records), so the data is
> there - but it won't show anything.
>
> If I set AllowCustomPaging to True, I get *slightly* better results; it
> will display items from the first page. However, it still isn't working
> right. If I call DataBind() during PageIndexChanged(), it stops displaying
> anything after the first click on a number, even if I go back to page 1;
> if I take that DataBind() line out, it always displays the first page
> only, AND I have to click each number twice to make it show the other page
> number as selected.
>
> According to what I read, custom paging should be done if you can make
> queries that only contain that pageful; this is not what I want - if I
> could make such queries then I wouldn't need the paging facility, I could
> implement paging myself with an URL parameter to say which page index.
>
> This is why I wanted paging without custom paging - I want to supply the
> query that returns ALL records from the table, and have the grid control
> page through them. So the first option is the right one, but I don't
> understand why it refuses to show any records.
>
> Help?
>
> --
> Jason Teagle
> jason@teagster.co.uk
>
>
Date:Sun, 17 Jun 2007 10:57:54 -0400
Author:
|
|
|