paging problem

Discussion in 'ASP .Net' started by Brad, Mar 28, 2005.

  1. Brad

    Brad Guest

    Why would this not work?
    //
    Private Sub nNext_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles nNext.Click
    dgTopTen.CurrentPageIndex += 1
    dgTopTen.DataBind()
    End Sub
    \\

    I get this error message here: Invalid CurrentPageIndex value. It must be >=
    0 and < the PageCount

    I have also tried something like this:
    //
    Private Sub dgHistory_PageIndexChanged(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
    dgHistory.PageIndexChanged
    dgTopTen.CurrentPageIndex = e.NewPageIndex
    dgTopTen.DataBind()
    End Sub
    \\

    With this one my first 5 records are still shown.

    I am all new to this so I appreciate and thank you for the help in what I am
    missing.

    Brad
     
    Brad, Mar 28, 2005
    #1
    1. Advertising

  2. Brad

    Elton Wang Guest

    Hi Brad,

    In order to page, you need re-bind datagrid's data source:

    dgTopTen.CurrentPageIndex = e.NewPageIndex
    dgTopTen.DataSource = GetDataSource ' Get data source from
    Session or db
    dgTopTen.DataBind()

    HTH

    Elton Wang



    >-----Original Message-----
    >Why would this not work?
    >//
    >Private Sub nNext_Click(ByVal sender As System.Object,

    ByVal e As
    >System.EventArgs) Handles nNext.Click
    > dgTopTen.CurrentPageIndex += 1
    > dgTopTen.DataBind()
    >End Sub
    >\\
    >
    >I get this error message here: Invalid CurrentPageIndex

    value. It must be >=
    >0 and < the PageCount
    >
    >I have also tried something like this:
    >//
    >Private Sub dgHistory_PageIndexChanged(ByVal sender As

    Object, ByVal e As
    >System.Web.UI.WebControls.DataGridPageChangedEventArgs)

    Handles
    >dgHistory.PageIndexChanged
    >dgTopTen.CurrentPageIndex = e.NewPageIndex
    >dgTopTen.DataBind()
    >End Sub
    >\\
    >
    >With this one my first 5 records are still shown.
    >
    >I am all new to this so I appreciate and thank you for

    the help in what I am
    >missing.
    >
    >Brad
    >
    >
    >
    >.
    >
     
    Elton Wang, Mar 28, 2005
    #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. Hajime Kusakabe

    DataGrid - sorting/paging problem

    Hajime Kusakabe, Jul 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    488
    Saravana
    Jul 31, 2003
  2. joedivec

    Paging Problem .NET

    joedivec, Aug 18, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    354
    joedivec
    Aug 18, 2003
  3. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,703
    Scott Allen
    Oct 8, 2004
  4. wh1974
    Replies:
    0
    Views:
    2,439
    wh1974
    Jan 12, 2005
  5. Red
    Replies:
    1
    Views:
    724
Loading...

Share This Page