Home All Groups Group Topic Archive Search About

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

Author
13 Jan 2006 9:05 PM
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?

Author
13 Jan 2006 9:27 PM
Phillip Williams
Databind during the page_load only if not Page.IsPostBack.
Show quoteHide quote
"Daves" wrote:

> 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?
>
>
>
Author
13 Jan 2006 11:11 PM
Daves
not possible because the GridView's page & sorting functions also use
PostBack!


Show quoteHide quote
"Phillip Williams" <Phillip.Willi***@webswapp.com> wrote in message
news:0CBC1454-FC8F-4A1D-A506-D0C00419CDED@microsoft.com...
> Databind during the page_load only if not Page.IsPostBack.
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Daves" wrote:
>
>> 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?
>>
>>
>>
Author
13 Jan 2006 11:49 PM
Phillip Williams
Try databinding during the page_PreRender stage after all other events are
processed.
Show quoteHide quote
"Daves" wrote:

> not possible because the GridView's page & sorting functions also use
> PostBack!
>
>
> "Phillip Williams" <Phillip.Willi***@webswapp.com> wrote in message
> news:0CBC1454-FC8F-4A1D-A506-D0C00419CDED@microsoft.com...
> > Databind during the page_load only if not Page.IsPostBack.
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Daves" wrote:
> >
> >> 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?
> >>
> >>
> >>
>
>
>
Author
16 Jan 2006 7:08 AM
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?