Not working for allow paging in datagrid

Discussion in 'ASP .Net Datagrid Control' started by Krishna, Feb 14, 2007.

  1. Krishna

    Krishna Guest

    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
    Krishna, Feb 14, 2007
    #1
    1. Advertising

  2. 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"


    "Krishna" <> wrote in message
    news:...
    > 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
    >
    >
    Bruno Alexandre, Feb 14, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maziar Aflatoun

    DataGrid Allow Paging next and previous

    Maziar Aflatoun, Jan 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,044
    Hermit Dave
    Jan 25, 2004
  2. Luis Esteban Valencia

    Dont allow datagrid paging if changes are detected

    Luis Esteban Valencia, Jan 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,149
    Saravana
    Jan 7, 2005
  3. wh1974
    Replies:
    0
    Views:
    2,402
    wh1974
    Jan 12, 2005
  4. Jeff
    Replies:
    2
    Views:
    916
    clintonG
    Sep 19, 2006
  5. Ryan Taylor
    Replies:
    1
    Views:
    662
    Ryan Taylor
    Sep 9, 2004
Loading...

Share This Page