Manually updating / paging / binding a DataSet to a GridView

Last post 02-02-2007 10:04 PM by boebelb. 1 replies.

Sort Posts:

  • Manually updating / paging / binding a DataSet to a GridView

    02-02-2007, 7:02 PM
    • Loading...
    • daleatzoi
    • Joined on 01-30-2007, 1:38 AM
    • Posts 7

    Hi all,  first warning: I am new to all this so I could be approaching this completely wrong.  Your patience is appreciated.

    I am developing a form that initiates a search and displays results in a GridView.  The problem is my source of data is a weird api that operates like so:  1. Initiate search 2. Poll api until the search finishes 3. retrieve final results in XML string.  This quirkiness prevents me from using a traditional ObjectDataSource or the like.

    I have developed a custom class that handles creation, polling, and manipulation of the results into a DataSet object.  I understand this is the best way to have all the data available and persistant so I can create a rich user experience with the GridView without having to poll the API again.  What I want to happen on my results page is an empty GridView to be present while the custom API Class is initiating/polling the API.  When it finishes, I want to update the GridView with the final results.

    I have the gridview created in my results page empty.  Then with a button click I create a new instance of my custom API class, and poll until the search is finished, then retrieve the dataset and bind manually.  This works and displays the first page of my results.  The problem is sorting doesn't work and even with instructions from ( http://community.strongcoders.com/content/CSGridViewSortingPaging.aspx ) the paging always returns like its working with an empty DataSet and doesn't seem to fire the OnPageChanging event.  I'm wondering if its a scope issue and my Object isn't persisting.

     Next I tried to use an ObjectDataSource tied to my API Object and bind Update() to a MyObject.GetResults() that returns the DataSet for my custom class.  This forces an instantiation of my API class, where the inital DataSet is blank (and hence the GridView).  Then I run the subs that fill in the dataset, but I can't figure out how to force the GridView to reload the DataSet.

     

    Sorry if this is vague or useless without code.  I'm still figuring out this whole data layers stuff in ASP.NET.  Thank you in advance.  
     

  • Re: Manually updating / paging / binding a DataSet to a GridView

    02-02-2007, 10:04 PM
    • Loading...
    • boebelb
    • Joined on 01-21-2006, 2:17 PM
    • Lawrenceville, GA
    • Posts 85

    Once you click the button, the server poll's your API, creates a DataSet object, binds the GridView to that DataSet, returns the page down to the client, and that DataSet object is out of scope and gone.  You either have to persist that data somewhere or query it again with each postback.  When the GridView is bound to a datasource control, that datasource control is querying its source on each postback (sort event, page event, etc) and rebinding each time.

    Perhaps you can handle the paging and sorting outside of the GridView, and each postback will send the page and sort order it needs to the API?  Or you can grab the DataSet and try storing it in Session or Cache, but doing so is not very scalable if the datasets are large and there will be a lot of users accessing it since both techniques are using server memory.

     

     

     

Page 1 of 1 (2 items)
Microsoft Communities
Page view counter