Paging In GridView bound to DataSet

Discussion in 'ASP .Net Web Controls' started by ES, Oct 4, 2006.

  1. ES

    ES Guest

    Is there a reasonable way to implement paging in a GridView control that's
    bound to a DataSet rather than a SqlDataSource? What needs to be done?

    Thanks
     
    ES, Oct 4, 2006
    #1
    1. Advertising

  2. ES

    ReyN Guest

    ReyN, Oct 5, 2006
    #2
    1. Advertising

  3. ES

    ReyN Guest

    ReyN, Oct 5, 2006
    #3
  4. ES

    ES Guest

    Thanks for your reply.
    I initially just bound the GridView to the DataSet, and ran it. It worked fine until I clicked a page number. At that point it gave me an error about the OnPageIndexChanging being raised but not handled, so I implemented it as such:
    protected void gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e) {

    gvSrchMatch.PageIndex = e.NewPageIndex;

    }

    This runs, but does not page correctly. The help file on this event speaks of canceling the move to the next page, but not actually making the control move to the next page.

    Interestingly, your demo crashes when you click a page link...

    Elton

    "ReyN" <> wrote in message news:...
    >
    > ooops I posted the wrong link that's in my local host :) so here goes
    >
    > http://authors.aspalliance.com/aspxtreme/sys/web/ui/webcontrols/demos/gridviewdatasource.aspx
    >
     
    ES, Oct 5, 2006
    #4
  5. ES

    ReyN Guest

    you have to rebind the GridView after setting the PageIndex in the
    event handler
     
    ReyN, Oct 6, 2006
    #5
  6. ES

    ES Guest

    Thanks, I repopulated the grid, set the index, and bound and it appears to work. I think caching the dataset might make it more efficient. It seems wrong to get the whole dataset each time...

    protected void gvSrchMatch_PageIndexChanging(object sender, GridViewPageEventArgs e) {

    gvSrchMatch.DataSource = PvrProfile.GetMatches(txtSrchLastName.Text);

    gvSrchMatch.PageIndex = e.NewPageIndex;

    gvSrchMatch.DataBind();

    }


    "ReyN" <> wrote in message news:...
    >
    > you have to rebind the GridView after setting the PageIndex in the
    > event handler
    >
     
    ES, Oct 10, 2006
    #6
    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. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,773
    Scott Allen
    Oct 8, 2004
  2. Replies:
    2
    Views:
    3,153
  3. Replies:
    1
    Views:
    344
    Ben Rush
    Apr 3, 2007
  4. Lee Boozer

    GridView bound to DataSet binds to...what precisely?

    Lee Boozer, May 26, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    114
    Lee Boozer
    May 26, 2006
  5. mgbee
    Replies:
    0
    Views:
    180
    mgbee
    May 11, 2006
Loading...

Share This Page