Paging not working in a datagrid

Discussion in 'ASP .Net Datagrid Control' started by J. Muenchbourg, May 27, 2004.

  1. I'm trying to use paging in a datagrid, but I can't get past the "cannot
    compute Count for a data source that does not implement ICollection"
    application error, as it does not point to a line in the code. Does the
    same thing even when i change the AllowCustomPaging property to
    AllowPaging . Wondering how to enable ICollection for the datasource:

    ''''
    Sub myDataGrid_PageChanger(Source As Object, _
    E As DataGridPageChangedEventArgs)
    ' Set the CurrentPageIndex before binding the grid
    myDataGrid.CurrentPageIndex = E.NewPageIndex
    BindData
    End Sub
    ''''

    <form runat="server" method="post">
    <asp:Datagrid runat="server"
    Id="MyDataGrid"
    GridLines="Both"
    cellpadding="0"
    cellspacing="0"
    Headerstyle-BackColor="#9999ff"
    Headerstyle-Font-Name="Arial"
    Headerstyle-Font-Size="12"
    Headerstyle-Font-Bold="True"
    BackColor="#00ffff"
    Font-Name="Arial"
    Font-Size="11"
    BorderColor="Black"
    showfooter="true"
    footerstyle-BackColor="#9999ff"
    footerstyle-Font-Name="Arial"
    AlternatingItemStyle-BackColor="#ffffff"
    AutogenerateColumns="False"
    OnEditcommand="MyDataGrid_EditCommand"
    OnCancelcommand="MyDataGrid_Cancel"
    OnUpdateCommand="MyDataGrid_UpdateCommand"
    AllowCustomPaging="True"
    PageSize="10"
    PagerStyle-Mode="NextPrev"
    PagerStyle-NextPageText="Next ->"
    pagerstyle-prevpagetext="<- Previous"
    PagerStyle-Font-Bold="True"
    OnPageIndexChanged="myDataGrid_PageChanger">

    </asp:DataGrid>
    </form>
    '''''

    Thanks in advance
    Muench



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    J. Muenchbourg, May 27, 2004
    #1
    1. Advertising

  2. J. Muenchbourg

    David Guest

    The grid datasource has to be class implement ICollection such as arraylist, DataView
    If you are using cutomizing page, VirtualPagenumber has to set to the count of the data source
     
    David, May 27, 2004
    #2
    1. Advertising


  3. >The grid datasource has to be class implement ICollection >such as

    arraylist, DataView.
    ?????????
    >If you are using cutomizing page,
    >VirtualPagenumber has to
    >set to the count of the data >>source.

    ????

    i appreciate your help dave, but can you or anyone be more specific?
    thanks
    muench

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    J. Muenchbourg, May 27, 2004
    #3
  4. J. Muenchbourg

    Rick Spiewak Guest

    What is your datasource? If it is a collection, it should inherit from
    collectionbase or another collection type which implements IEnumerable, etc.

    "J. Muenchbourg" <> wrote in message
    news:Ofoa%...
    >
    > I'm trying to use paging in a datagrid, but I can't get past the "cannot
    > compute Count for a data source that does not implement ICollection"
    > application error, as it does not point to a line in the code. Does the
    > same thing even when i change the AllowCustomPaging property to
    > AllowPaging . Wondering how to enable ICollection for the datasource:
    >
    > ''''
    > Sub myDataGrid_PageChanger(Source As Object, _
    > E As DataGridPageChangedEventArgs)
    > ' Set the CurrentPageIndex before binding the grid
    > myDataGrid.CurrentPageIndex = E.NewPageIndex
    > BindData
    > End Sub
    > ''''
    >
    > <form runat="server" method="post">
    > <asp:Datagrid runat="server"
    > Id="MyDataGrid"
    > GridLines="Both"
    > cellpadding="0"
    > cellspacing="0"
    > Headerstyle-BackColor="#9999ff"
    > Headerstyle-Font-Name="Arial"
    > Headerstyle-Font-Size="12"
    > Headerstyle-Font-Bold="True"
    > BackColor="#00ffff"
    > Font-Name="Arial"
    > Font-Size="11"
    > BorderColor="Black"
    > showfooter="true"
    > footerstyle-BackColor="#9999ff"
    > footerstyle-Font-Name="Arial"
    > AlternatingItemStyle-BackColor="#ffffff"
    > AutogenerateColumns="False"
    > OnEditcommand="MyDataGrid_EditCommand"
    > OnCancelcommand="MyDataGrid_Cancel"
    > OnUpdateCommand="MyDataGrid_UpdateCommand"
    > AllowCustomPaging="True"
    > PageSize="10"
    > PagerStyle-Mode="NextPrev"
    > PagerStyle-NextPageText="Next ->"
    > pagerstyle-prevpagetext="<- Previous"
    > PagerStyle-Font-Bold="True"
    > OnPageIndexChanged="myDataGrid_PageChanger">
    >
    > </asp:DataGrid>
    > </form>
    > '''''
    >
    > Thanks in advance
    > Muench
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Rick Spiewak, May 28, 2004
    #4
  5. Like the last response, the code you see is what I'm working with.
    Without the paging attributes, this script works fine. I have no idea if
    youre talking about the namescpae references: <%@ Import
    Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SQLClient" %>,
    or where the Icollection would be .
    Thanks
    Muench

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    J. Muenchbourg, May 29, 2004
    #5
    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. Coleen

    Datagrid Paging not working

    Coleen, Dec 31, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    4,521
    Coleen
    Dec 31, 2003
  2. wh1974
    Replies:
    0
    Views:
    2,470
    wh1974
    Jan 12, 2005
  3. Red
    Replies:
    1
    Views:
    752
  4. Replies:
    0
    Views:
    482
  5. getziiiiiiiiiii

    PAGING not working in ASP DataGrid

    getziiiiiiiiiii, Mar 12, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    814
Loading...

Share This Page