Where did my GridView go? (Ajax)

Last post 05-09-2008 9:33 AM by yosamite. 9 replies.

Sort Posts:

  • Where did my GridView go? (Ajax)

    05-08-2008, 10:18 AM
    • Loading...
    • yosamite
    • Joined on 03-28-2008, 8:14 PM
    • Posts 24

    I have 4 GridViews on my page. They all had asynch postback enabled, which worked great. However, sometimes the queries take an extremely long time, so I needed a way to show end-users that something was actually happening. I threw in an UpdateProgress control, then put each one of my GridViews into their own UpdatePanel. This works great, the little image displays on the page, and everyone is happy - sort of. If I sort by a column in one GridView, then jump to the next, and start the sort there, I can see the UpdateProgress pop up, do its thing, and then bam - GridView vanishes. Poof. After that, sorting or paging ANY other GridView causes them to leave the page as well. This is my first dive into AJAX, so I'm not really sure what's going on or how to handle this. Shouldn't it just stop the other callback and move on to the next if another column is clicked? 

  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 11:04 AM
    • Loading...
    • vgiambattista
    • Joined on 01-13-2006, 2:40 PM
    • Atlanta, GA
    • Posts 91

    yousamite,

    Does the vanishing occur if you remove the UpdateProgress control?

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 11:40 AM
    • Loading...
    • yosamite
    • Joined on 03-28-2008, 8:14 PM
    • Posts 24

     Yes it does.

  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 11:40 AM
    • Loading...
    • yosamite
    • Joined on 03-28-2008, 8:14 PM
    • Posts 24
    However, if I take the UpdatePanels out and use the regular  EnableSortingAndPagingCallbacks="true", it works fine.
  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 1:23 PM
    • Loading...
    • vgiambattista
    • Joined on 01-13-2006, 2:40 PM
    • Atlanta, GA
    • Posts 91

    yosamite,

    I tried this out with a test app.  Each postback is cancelling out the previous one when you use multiple UpdatePanels.

    Fortunately, DisturbedBuddha (who is on these boards alot) has a nice post about it along with a solution: '>here.

    He even provides a javascript block that you can insert under your scriptmanager to queue up your async calls.  Works like a charm, though it may take longer for everything to finish updating (compared to using SortPageCallbacks), since the calls now have to wait on each other.

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 2:17 PM
    • Loading...
    • yosamite
    • Joined on 03-28-2008, 8:14 PM
    • Posts 24

    Your link got all fuddled up...can you re-link that? 

  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 2:51 PM
    • Loading...
    • vgiambattista
    • Joined on 01-13-2006, 2:40 PM
    • Atlanta, GA
    • Posts 91

    Sorry.  Let's try it the old fashioned way, copy and paste:

    http://disturbedbuddha.wordpress.com/2007/12/12/handling-multiple-asynchronous-postbacks/

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 3:15 PM
    • Loading...
    • yosamite
    • Joined on 03-28-2008, 8:14 PM
    • Posts 24

     That worked great, but led me to a new issue: now, the calls are all queued, however the UpdateProgress does not stick around for more than the first item.

     

    I think, if I knew JavaScript, I could throw something into this block that tells the UpdateProgress to load, but I don't know JS sadly:

            function EndRequestHandler(sender, args) {
                if (pbQueue.length > 0) {
                    __doPostBack(pbQueue.shift(), argsQueue.shift());          
                }
            }

    Since I am assuming the UpdateProgress can't see the event because it is being fired off of the queue and not the Page?

  • Re: Where did my GridView go? (Ajax)

    05-08-2008, 3:54 PM
    • Loading...
    • vgiambattista
    • Joined on 01-13-2006, 2:40 PM
    • Atlanta, GA
    • Posts 91

    yosamite,

    It's a slightly different scenario, but this link should give you a good way to plug in some extra javascript to get it working: http://fredrik.nsquared2.com/viewpost.aspx?PostID=407  At least, I think you should be able to cobble it all together, though I havn't tried it myself.

    James

    James Ashley, Magenic Technologies
    (james.ashley.magenic@gmail.com)
  • Re: Where did my GridView go? (Ajax)

    05-09-2008, 9:33 AM
    • Loading...
    • yosamite
    • Joined on 03-28-2008, 8:14 PM
    • Posts 24

    I tried playing with this, and sort of got it to work:


            function EndRequestHandler(sender, args) {
                if (pbQueue.length > 0) {
                    __doPostBack(pbQueue.shift(), argsQueue.shift());
                    if( args.get_postBackElement().id == 'GV1' )
                        $get('UpdateProgress1').style.display = 'block';
                }
            }

    This actually works perfectly, however, it always errors with the following:

     

    Microsoft JScript runtime error: Object doesn't support this property or method

     

    With this line highlighted in VS:            if( args.get_postBackElement().id == 'GV1' )

Page 1 of 1 (10 items)