Datagrid paging more than 20 pages

K

Kalvin

I am using the datagrid. I have allowpaging=true. I load the data and
there is about 7000 records. At the bottom there is pages 1 through 10
and (...). The first time I click on (...) it takes me to pages 11
through 20. If I choose 12 it takes me to page 2. If I choose (...)
it goes to pages 1 through 10 again. In the pageindexChanged event, if
I explicitly set the .CurrentPageindex to a value it works fine. Am I
missing a step here? Please help.

Kalvin

/* BEGIN CODE */
Private Sub uiReports_PageIndexChanged(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
uiReports.PageIndexChanged
uiReports.CurrentPageIndex = e.NewPageIndex
uiReports.DataBind()

End Sub

*/
 
K

Kalvin

Found a fix. Would love an explanation so I will understand.

If I set the EnableViewState on the grid to false, it will not page
correctly.
If I set it to True, it will page just like it should.

Is this by design, or by accident?

Kalvin
 
B

billmiami2

Kalvin,

Much of the functionality of the datagrid depends on having the
viewstate enabled. For example, a number of events will no longer fire
when you disable the viewstate. Unfortunately, keeping the viewstate
enabled tends to significantly bloat your page. Take a look at the the
HTML after your page is rendered (make sure you turn on text /word
wrapping) and you will probably notice that half of the html in your
page is dedicated to the viewstate, and probably almost all of it for
your datagrid.

An alternative is to create your own paging mechanism with code so that
you can turn off the viewstate on the datagrid. Try the link below for
a start.

http://www.mastercsharp.com/article.aspx?ArticleID=76&&TopicID=2

I have a user control that I made using a repeater that has the
sorting, paging, and other functionality bundled into it. Viewstate is
turned off. In this way, I don't need to rely on the datagrid to get
that functionality.

Bill E.
 

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

Similar Threads

Webforms Datagrid Sorting/Paging... 2
Paging a datagrid 1
Invalid Index in paging 3
datagrid paging 2
FormView - Paging 0
paging problem 1
Datagrid paging 2
DataGrid - Paging problems 1

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top