button's OnClick event runs after page databinding...

D

Daves

a GridView control iterates users in my database and below it there are
search fields and Search button which applies filter expression to the
SqlDataSource.

The GridView is manually databound in the Page_Load event and I also persist
this databinding since the GridView uses postback since it users paging and
sorting options. Now, if the Search button is used, it's OnClick event is
run *AFTER* the Page_Load event so if I use it, I am actually databinding
twice!

Is there some way for me to check in the Page_Load if the Search button was
used or how can I handle this situation?
 
P

Phillip Williams

Try databinding during the page_PreRender stage after all other events are
processed.
 
K

Keith Patrick

The gridview should be storing the data it retrieved in its viewstate and
restore the control's state (and that of its rows) on postback without the
need to databind. Are you saying that paging/sorting is somehow interfering
with that process for you?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top