Problem with Post Back and User Control

Discussion in 'ASP .Net Web Controls' started by James Todman, Oct 12, 2004.

  1. James Todman

    James Todman Guest

    I have a user control that contains a data grid type control (it's part of a
    3rd party DAL), a text box and a button. When the button is clicked it takes
    the text and stores it in the database. I then want the data grid to re-bind
    to the datasource, refresh itself, so that when the page is then rendered
    afterwards, the data is shown.

    I've added an OnClick event handler for the button that adds the data to the
    database, it then resets the grid, rebinds and refreshes. However, this for
    some reason doesn't actually show the updated data until I re-navigate to
    the page.

    If I change the code so that the update is done during the user control's
    OnLoad event and check the IsPostback property and handle the update inside
    there it works. However, I only want to store the data if they click on the
    button inside the user control. There are other controls that can cause a
    postback, and I don't want the data to be stored when another button is
    clicked.

    My question is, is this the intended behaviour? It seems that rendering is
    performed before the event is handled. Should the control be doing something
    else to ensure that the grid is refreshed by the time the page comes to
    render?

    Cheers,
    James
    James Todman, Oct 12, 2004
    #1
    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. sk2000
    Replies:
    2
    Views:
    4,428
    Kumar
    Nov 12, 2003
  2. Joby
    Replies:
    0
    Views:
    1,628
  3. Replies:
    0
    Views:
    650
  4. =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?=

    User Control and Post Back

    =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?=, Jul 1, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    678
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 2, 2006
  5. =?Utf-8?B?Z29yaWxsYQ==?=
    Replies:
    1
    Views:
    766
    Masudur
    May 25, 2007
Loading...

Share This Page