Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Paging

Status
Not open for further replies.

SBTBILL

Programmer
May 1, 2000
515
0
0
US
I am trying to add paging to a web grid. I have the grid working nicely without it.

I got an error about page events so went through the posts here and found code similar to this.

Protected Sub gvitems_PageIndexChanging(ByVal sender As Object, ByVal g As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdpv.PageIndexChanging

grdpv.PageIndex = g.NewPageIndex

End Sub

Modifing that to the above got rid of the crash but the page doesn't change.

I've also seen stuff about making the data connection a session variable. How do you do that?
 
the code above simply sets the gridview paging index. you also need to fetch the data and bind it to the grid.

btw: if you only enable paging at the UI level you performance will still suffer because webforms will put all the data into the viewstate (assuming it's enabled).

to really see a preformance boost you need the query to page to do the paging. this will require 2 queries.
1. the page of data
2. the total number of records (so paging actually works)

then you need to create a custom datasource to bind to the grid passing the page of data and total item count. this will allow you to efficiently page data at the database level.

how the query implements paging is determined by:
1. the framework used to write the sql statements
2. the database

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top