Problem with Post Back and User Control

J

James Todman

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
 

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

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top