Error when setting AllowPaging to True on Datagrid


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Error when setting AllowPaging to True on Datagrid

  1. #1
    Kerry Guest

    Error when setting AllowPaging to True on Datagrid


    Hello,

    Does anyone know why I would be getting the following error when I set
    the AllowPaging propery to True on my Datagrid (dgResults)? I have tried
    to set it up like I have seen in several examples but I countinue to get
    the following error:

    AllowCustomPaging must be true and VirtualItemCount must be set for a DataGrid
    with ID dgResults when AllowPaging is set to true and the selected datasource
    does not implement ICollection.

    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information about
    the error and where it originated in the code.

    Exception Details: System.Web.HttpException: AllowCustomPaging must be true
    and VirtualItemCount must be set for a DataGrid with ID dgResults when AllowPaging
    is set to true and the selected datasource does not implement ICollection.

    Source Error:


    Line 114: ' display results in a Datagrid on the form.
    Line 115: dgResults.DataSource = dr
    Line 116: dgResults.DataBind()
    Line 117: lblPageCount.Visible = True
    Line 118: lblPageCount.Text = "Page " & (dgResults.CurrentPageIndex
    + 1) & " of " & (dgResults.PageCount)

    Any help would be much appreciated. Thanks,

    Kerry
    kelleyk@somc.org

  2. #2
    David Rothgery Guest

    Re: Error when setting AllowPaging to True on Datagrid

    DataReaders don't implement the ICollection interface, which the built-in
    paging functionality for DataGrids uses.

    You either have to use a DataSet, or set AllowCustomPaging to True on your
    DataGrid and build your own paging.

    "Kerry" <kelleyk@somc.org> wrote in message
    news:3ef1b63f$1@tnews.web.devx.com...
    >
    > Hello,
    >
    > Does anyone know why I would be getting the following error when I set
    > the AllowPaging propery to True on my Datagrid (dgResults)? I have tried
    > to set it up like I have seen in several examples but I countinue to get
    > the following error:
    >
    > AllowCustomPaging must be true and VirtualItemCount must be set for a

    DataGrid
    > with ID dgResults when AllowPaging is set to true and the selected

    datasource
    > does not implement ICollection.
    >
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information

    about
    > the error and where it originated in the code.
    >
    > Exception Details: System.Web.HttpException: AllowCustomPaging must be

    true
    > and VirtualItemCount must be set for a DataGrid with ID dgResults when

    AllowPaging
    > is set to true and the selected datasource does not implement ICollection.
    >
    > Source Error:
    >
    >
    > Line 114: ' display results in a Datagrid on the form.
    > Line 115: dgResults.DataSource = dr
    > Line 116: dgResults.DataBind()
    > Line 117: lblPageCount.Visible = True
    > Line 118: lblPageCount.Text = "Page " &

    (dgResults.CurrentPageIndex
    > + 1) & " of " & (dgResults.PageCount)
    >
    > Any help would be much appreciated. Thanks,
    >
    > Kerry
    > kelleyk@somc.org




  3. #3
    Kerry Guest

    Re: Error when setting AllowPaging to True on Datagrid



    Thanks David,
    I just changed it to use a dataset and it is working now. Thanks again.

    Kerry

    "David Rothgery" <drothgery@alum.wpi.edu> wrote:
    >DataReaders don't implement the ICollection interface, which the built-in
    >paging functionality for DataGrids uses.
    >
    >You either have to use a DataSet, or set AllowCustomPaging to True on your
    >DataGrid and build your own paging.
    >
    >"Kerry" <kelleyk@somc.org> wrote in message
    >news:3ef1b63f$1@tnews.web.devx.com...
    >>
    >> Hello,
    >>
    >> Does anyone know why I would be getting the following error when I set
    >> the AllowPaging propery to True on my Datagrid (dgResults)? I have tried
    >> to set it up like I have seen in several examples but I countinue to get
    >> the following error:
    >>
    >> AllowCustomPaging must be true and VirtualItemCount must be set for a

    >DataGrid
    >> with ID dgResults when AllowPaging is set to true and the selected

    >datasource
    >> does not implement ICollection.
    >>
    >> Description: An unhandled exception occurred during the execution of the
    >> current web request. Please review the stack trace for more information

    >about
    >> the error and where it originated in the code.
    >>
    >> Exception Details: System.Web.HttpException: AllowCustomPaging must be

    >true
    >> and VirtualItemCount must be set for a DataGrid with ID dgResults when

    >AllowPaging
    >> is set to true and the selected datasource does not implement ICollection.
    >>
    >> Source Error:
    >>
    >>
    >> Line 114: ' display results in a Datagrid on the form.
    >> Line 115: dgResults.DataSource = dr
    >> Line 116: dgResults.DataBind()
    >> Line 117: lblPageCount.Visible = True
    >> Line 118: lblPageCount.Text = "Page " &

    >(dgResults.CurrentPageIndex
    >> + 1) & " of " & (dgResults.PageCount)
    >>
    >> Any help would be much appreciated. Thanks,
    >>
    >> Kerry
    >> kelleyk@somc.org

    >


  4. #4
    Join Date
    Jul 2007
    Posts
    1

    Thumbs down dgResults error

    Does anyone know why I get this error when using dgResults:

    Compiler Error Message: CS0103: The name 'dgResults' does not exist in the current context

    Source Error:

    Line 33: dgResults.DataSource = ds;
    Line 34: dgResults.DataBind();
    Line 35: }

    Thanks,

    Xana

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center