Tuesday, April 5, 2011

Determine why Bound Data is not available at PostBack

I've got an ASP.NET GridView that's been extended to provide a "row click" functionality. I data bind anywhere from 1 to 10 records and display it to the user.

The bug I'm hitting is that the control will not have any data associated with it on postback.

I have observed this behavior only when I click on a row before the rest of the page is finished loading and can re-produce the problem, but I have no idea why it is occurring.

Any suggestions are much appreciated!

From stackoverflow
  • You are going to experience a lot of difficulty with ASP.NET postbacks when you trigger them before the page has a chance to finish loading. Postback events work by inserting values via javascript into hidden inputs on the page and submitting the main form. The problem is that if you trigger the postback early you cannot guarantee whether all the controls and the hidden inputs have been completely rendered.

    Gavin Miller : So obviously I can't control user action, there will be times where they click before a load finishes. Is there a good way to delay/control/circumvent/*shrug - other* this action?
    Andrew Hare : Unfortunately the best thing I can suggest is trim down your HTML so that it loads faster. Also you can create a javascript function that disables postback until the document has finished loading.

0 comments:

Post a Comment