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

Discussion in 'ASP .Net Web Controls' started by Daves, Jan 13, 2006.

  1. Daves

    Daves Guest

    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?
     
    Daves, Jan 13, 2006
    #1
    1. Advertising

  2. 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?
    >
    >
    >
     
    Phillip Williams, Jan 13, 2006
    #2
    1. Advertising

  3. Daves

    Daves Guest

    not possible because the GridView's page & sorting functions also use
    PostBack!


    "Phillip Williams" <> wrote in message
    news:...
    > 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?
    >>
    >>
    >>
     
    Daves, Jan 13, 2006
    #3
  4. Try databinding during the page_PreRender stage after all other events are
    processed.
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Daves" wrote:

    > not possible because the GridView's page & sorting functions also use
    > PostBack!
    >
    >
    > "Phillip Williams" <> wrote in message
    > news:...
    > > 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?
    > >>
    > >>
    > >>

    >
    >
    >
     
    Phillip Williams, Jan 13, 2006
    #4
  5. 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?
     
    Keith Patrick, Jan 16, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kathy Burke
    Replies:
    2
    Views:
    3,497
    Kathy Burke
    Oct 16, 2003
  2. Nosaj
    Replies:
    2
    Views:
    640
    Shamim
    Nov 29, 2005
  3. Stu
    Replies:
    2
    Views:
    795
    Rob McAninch
    Apr 6, 2004
  4. jobs
    Replies:
    0
    Views:
    1,631
  5. Replies:
    2
    Views:
    261
Loading...

Share This Page