CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2009
    Posts
    2

    datagrid paging not working

    Hi

    I have a page with a search button & a asp datagrid with paging enabled. In IE8 the grid displays correctly when I click the search button. But when I click on page 2 for example, the grid goes blank.

    Now, when I hover the cursor over the page2 link, i notice the doPostBack is missing the second parameter.

    eg: javascript: _doPostBack('ID$controlID$mygridID, '').
    Isn't it supposed to be javascript: _doPostBack('ID$controlID$mygridID, 'Page$2') or something like that? Where's the 'Page$2' param gone?

    in the ASPX:

    <aspataGrid id="mygridID" AutoGenerateColumns="False" EnableViewState="true" runat="server" AllowPaging="True" PageSize="5">
    <Columns>
    <asp:BoundColumn HeaderText="Name" DataField="Name"/>
    'etc..a few more columns
    </Columns>
    </aspataGrid>

    In the properties-events of the grid I tied the PageIndexChanged event to the code below:

    Protected Sub mygridID_PageIndexChanged(ByVal source As Object, ByVal e As DataGridPageChangedEventArgs) Handles myGridID.PageIndexChanged
    Dim ds As DataSet
    ds = Cache("dataset") 'already retrieved and cached the data in my search button method.
    myGridID.DataSource = ds
    myGridID.CurrentPageIndex = e.NewPageIndex
    myGridID.DataBind()
    End Sub

    If I replace the Datagrid with GridView doing basically the same thing it works, but I would like to know why my Datagrid paging doesn't work...I've gone through forums, articles etc for a few hours, but don't see any dealing with missing doPostBack param, or is it something else I missed?

    I'm using MS visual studio 2008 with .Net 3.5 SP1.

    any help is appreciated.

    Thanks.
    Ponstan

  2. #2
    Join Date
    Aug 2009
    Posts
    2

    Re: datagrid paging not working

    Ok turns out the event wasn't firing properly.

    I had to do a if not Page.IsPostBack in the page_load, then rebind the grid there as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured