Preventing databind when page is invalid
Posted on 2006-06-13
I have a page set up as follows:
A TextBox that accepts a value, which will be used as a parameter in the ObjectDataSource
A CustomValidator on that textbox (it checks to make sure the string represents a date)
A GridView, with an associated ObjectDataSource, having a SelectParameter set to the TextBox.
My problem is that the GridView rebinds on every postback, causing a problem if the textbox is invalid, the database will throw an exception. Ideally, I would like the page to simply display the form again, with the old GridView data, and an error message from the Validators. I thought this would be built in, because why would anybody want to use an invalid control as the source of a parameter.
If I'm confusing you, I can post snippets of my code to help clarify.