Datagrid custom paging always loads page 1

Discussion in 'ASP .Net Web Controls' started by Julia B, Apr 11, 2006.

  1. Julia B

    Julia B Guest

    Hi,

    I've got a datagrid where I've set up custom paging, following instructions
    in Help etc, however, although the virtualitemcount is correct (i.e. number
    of pages shown is correct), whatever page I click on the first 10 dataset
    items are always loaded. If anyone can help that would be great! Thanks in
    advance....

    Code below:

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    Me.PartDbConnection.ConnectionString = Global.ConnectionString

    'if the page isn't being loaded for the first time update the
    datagrid
    'with the session dataset
    If Me.IsPostBack Then
    PartDataSet1 = CType(Session("PartDataSet"), PartDataSet)
    'otherwise update the datagrid with the database info
    Else
    startIndex = 0
    PartDataAdapter.Fill(PartDataSet1)
    Session("PartDataSet") = PartDataSet1
    PartDataGrid.VirtualItemCount = PartDataSet1.Parts.Count
    PartDataGrid.DataBind()
    End If
    End Sub

    Private Sub PartDataGrid_PageIndexChanged(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
    PartDataGrid.PageIndexChanged
    PartDataGrid.CurrentPageIndex = e.NewPageIndex
    PartDataGrid.DataBind()
    End Sub

    Private Sub PartDataGrid_Page(ByVal sender As Object, ByVal e As
    DataGridPageChangedEventArgs)
    startIndex = e.NewPageIndex * PartDataGrid.PageSize
    PartDataGrid.CurrentPageIndex = e.NewPageIndex
    PartDataGrid.DataBind()
    End Sub
     
    Julia B, Apr 11, 2006
    #1
    1. Advertising

  2. The segment of code that you posted does not show the customization. It
    looks like the default navigation with default buttons to me.

    You might review those samples for how to customize the navigation:

    http://www.societopia.net/samples/dataGrid_3c.aspx

    http://msdn.microsoft.com/library/d...cifyingpagingbehaviorindatagridwebcontrol.asp
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Julia B" wrote:

    > Hi,
    >
    > I've got a datagrid where I've set up custom paging, following instructions
    > in Help etc, however, although the virtualitemcount is correct (i.e. number
    > of pages shown is correct), whatever page I click on the first 10 dataset
    > items are always loaded. If anyone can help that would be great! Thanks in
    > advance....
    >
    > Code below:
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > Me.PartDbConnection.ConnectionString = Global.ConnectionString
    >
    > 'if the page isn't being loaded for the first time update the
    > datagrid
    > 'with the session dataset
    > If Me.IsPostBack Then
    > PartDataSet1 = CType(Session("PartDataSet"), PartDataSet)
    > 'otherwise update the datagrid with the database info
    > Else
    > startIndex = 0
    > PartDataAdapter.Fill(PartDataSet1)
    > Session("PartDataSet") = PartDataSet1
    > PartDataGrid.VirtualItemCount = PartDataSet1.Parts.Count
    > PartDataGrid.DataBind()
    > End If
    > End Sub
    >
    > Private Sub PartDataGrid_PageIndexChanged(ByVal source As Object, ByVal e As
    > System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
    > PartDataGrid.PageIndexChanged
    > PartDataGrid.CurrentPageIndex = e.NewPageIndex
    > PartDataGrid.DataBind()
    > End Sub
    >
    > Private Sub PartDataGrid_Page(ByVal sender As Object, ByVal e As
    > DataGridPageChangedEventArgs)
    > startIndex = e.NewPageIndex * PartDataGrid.PageSize
    > PartDataGrid.CurrentPageIndex = e.NewPageIndex
    > PartDataGrid.DataBind()
    > End Sub
     
    Phillip Williams, Apr 11, 2006
    #2
    1. Advertising

  3. Julia B

    Julia B Guest

    Thanks Philip

    The Help documents I read weren't particularly intuitive or easy to
    understand and I didn't find the walkthrough. I'll work through it and see if
    I can get it to work.

    Julia
    "Phillip Williams" wrote:

    > The segment of code that you posted does not show the customization. It
    > looks like the default navigation with default buttons to me.
    >
    > You might review those samples for how to customize the navigation:
    >
    > http://www.societopia.net/samples/dataGrid_3c.aspx
    >
    > http://msdn.microsoft.com/library/d...cifyingpagingbehaviorindatagridwebcontrol.asp
    > --
    > HTH,
    > Phillip Williams
    > http://www.societopia.net
    > http://www.webswapp.com
    >
    >
    > "Julia B" wrote:
    >
    > > Hi,
    > >
    > > I've got a datagrid where I've set up custom paging, following instructions
    > > in Help etc, however, although the virtualitemcount is correct (i.e. number
    > > of pages shown is correct), whatever page I click on the first 10 dataset
    > > items are always loaded. If anyone can help that would be great! Thanks in
    > > advance....
    > >
    > > Code below:
    > >
    > > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles MyBase.Load
    > > Me.PartDbConnection.ConnectionString = Global.ConnectionString
    > >
    > > 'if the page isn't being loaded for the first time update the
    > > datagrid
    > > 'with the session dataset
    > > If Me.IsPostBack Then
    > > PartDataSet1 = CType(Session("PartDataSet"), PartDataSet)
    > > 'otherwise update the datagrid with the database info
    > > Else
    > > startIndex = 0
    > > PartDataAdapter.Fill(PartDataSet1)
    > > Session("PartDataSet") = PartDataSet1
    > > PartDataGrid.VirtualItemCount = PartDataSet1.Parts.Count
    > > PartDataGrid.DataBind()
    > > End If
    > > End Sub
    > >
    > > Private Sub PartDataGrid_PageIndexChanged(ByVal source As Object, ByVal e As
    > > System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
    > > PartDataGrid.PageIndexChanged
    > > PartDataGrid.CurrentPageIndex = e.NewPageIndex
    > > PartDataGrid.DataBind()
    > > End Sub
    > >
    > > Private Sub PartDataGrid_Page(ByVal sender As Object, ByVal e As
    > > DataGridPageChangedEventArgs)
    > > startIndex = e.NewPageIndex * PartDataGrid.PageSize
    > > PartDataGrid.CurrentPageIndex = e.NewPageIndex
    > > PartDataGrid.DataBind()
    > > End Sub
     
    Julia B, Apr 11, 2006
    #3
    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. anon
    Replies:
    0
    Views:
    470
  2. Haydnw
    Replies:
    5
    Views:
    476
    =?Utf-8?B?amdyYW50?=
    Sep 25, 2004
  3. wh1974
    Replies:
    0
    Views:
    2,452
    wh1974
    Jan 12, 2005
  4. Replies:
    5
    Views:
    404
  5. Oleg Ogurok

    Custom paging problems - first page always displayed

    Oleg Ogurok, Jul 8, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    128
    Oleg Ogurok
    Jul 8, 2003
Loading...

Share This Page