Not working for allow paging in datagrid

K

Krishna

hi,
I developed one web application using visual studio 2005 and created
one new webforms with datagrid control and set AllowPaging="true".But it's
not work on it
my code is below.

<asp:DataGrid id="testgrid" runat="server" EnableViewState="true"
Width="100%" AutoGenerateColumns="False" font-size="10pt" Font-Names="Arial"
BorderStyle="None" Gridlines="Both" DataKeyField="testId"
AllowPaging="true" PageSize="10" >

Imports System.Data
Imports System.Web.UI

Partial Class testclass
Inherits System.Web.UI.Page

Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
Me.InitializeComponent()
AddHandler MyBase.Load, AddressOf Me.LoadClass
AddHandler testgrid.PageIndexChanged, AddressOf
Me.testgrid_PageIndexChanged
MyBase.OnInit(e)
End Sub

Private Sub InitializeComponent()
End Sub

how to avoid the issue?
pls help
regards
krishna
Private Sub LoadClass(ByVal Sender As Object, ByVal E As System.EventArgs)
If (Me.IsPostBack = False) Then
'bind datagrid
Me.testgrid.PagerStyle.Mode = PagerMode.NumericPages
End If
End Sub


Private Sub testgrid_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs)
Me.timberDetails.CurrentPageIndex = e.NewPageIndex
Me.testgrid.DataSource = 'datasource'
Me.testgrid.DataBind()
End Sub
End class
 
B

Bruno Alexandre

remove 2 lines!
because you are binding the hole object again from start

Me.timberDetails.CurrentPageIndex = e.NewPageIndex
'Me.testgrid.DataSource = 'datasource'
'Me.testgrid.DataBind()

--

Bruno Alexandre
Stroby, Danmark

"a Portuguese in Denmark"
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top