AllowPaging not working

G

Guest

I have a datagrid that I set the PageSize = 10 and AllowPaging = True,
however when I display the page in my browser, it shows 10 rows and the
paging arrows but does not page when I click the "Next" hyperlink. Does
anyone know of a problem with this feature?
 
M

Marina

You have to manually handle the event for this, and rebind the data. From
what I recall, you don't get this completely for free.
 
G

Guest

Do you know where I can find the OnPageIndexChanged event handler on the
datagrid? There does not seem to be a property setting on the property
window for the datagrid. Do you have an example of a subroutine that does
paging?
 
G

Guest

This code does not seem to work:

Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As DataGridPageChangedEventArgs)
DataGrid1.CurrentPageIndex = e.NewPageIndex
DataGrid1.DataBind()
End Sub
 
G

Guest

Simple VB code. -Shaw

Private Sub dgd_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
dgd.PageIndexChanged
'Change pages on the grid.
dgd.CurrentPageIndex = e.NewPageIndex

Dim dtView As DataView = CType(Cache("MyDataView"), DataView)
If Not (dtView Is Nothing) Then
dgd.DataSource = dtView
dgd.DataBind()
End If
End Sub
 
G

Guest

Thank you for the code but I still can't get it to work. Your code contains
the syntax: CType(Cache("MyDataView"), DataView) What would I put in the
"MyDataView" portion of this statement? My datagrid is name "DataGrid1" and
I am assuming this is not what you mean.
 
M

Marina

He is getting the DataView, because that is the datasource for the grid. You
need to get whatever you are using as the datasource, and rebind it to the
grid.

If you are storing your data in cache or session in between requests, then
you need to get it from there. If you aren't storing it anywhere, you need
to requery the database, and then rebind the data.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top