Home All Groups Group Topic Archive Search About

Paging In GridView bound to DataSet

Author
4 Oct 2006 9:37 PM
ES
Is there a reasonable way to implement paging in a GridView control that's
bound to a DataSet rather than a SqlDataSource?  What needs to be done?

Thanks

Author
4 Oct 2006 11:33 PM
ReyN
you don't have to change anything

paging will work in a GridView whether it's bound to SqlDataSource or a
DataSet

http://raven/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx
Author
4 Oct 2006 11:37 PM
ReyN
ooops I posted the wrong link that's in my local host :) so here goes

http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx
Author
5 Oct 2006 1:50 PM
ES
Thanks for your reply.
I initially just bound the GridView to the DataSet, and ran it.  It worked fine until I clicked a page number.  At that point it gave me an error about the OnPageIndexChanging being raised but not handled, so I implemented it as such:
protected void gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e) {

    gvSrchMatch.PageIndex = e.NewPageIndex;

}

This runs, but does not page correctly.  The help file on this event speaks of canceling the move to the next page, but not actually making the control move to the next page.

Interestingly, your demo crashes when you click a page link...

Elton

Show quoteHide quote
"ReyN" <rvnu***@hotmail.com> wrote in message news:1160005059.054713.53370@e3g2000cwe.googlegroups.com...
>
> ooops I posted the wrong link that's in my local host :) so here goes
>
> http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx
>
Author
6 Oct 2006 9:11 AM
ReyN
you have to rebind the GridView after setting the PageIndex in the
event handler
Author
10 Oct 2006 5:36 PM
ES
Thanks,  I repopulated the grid, set the index, and bound and it appears to work.  I think caching the dataset might make it more efficient.  It seems wrong to get the whole dataset each time...

protected void gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e) {

    gvSrchMatch.DataSource = PvrProfile.GetMatches(txtSrchLastName.Text);

    gvSrchMatch.PageIndex = e.NewPageIndex;

    gvSrchMatch.DataBind();

}


Show quoteHide quote
"ReyN" <rvnu***@hotmail.com> wrote in message news:1160125886.530853.110650@h48g2000cwc.googlegroups.com...
>
> you have to rebind the GridView after setting the PageIndex in the
> event handler
>