Paging In GridView bound to DataSet

E

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
 
E

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
 
E

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();

}
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top