Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating via a dynamic WebUserControl

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I have a web form which allows a user to search on data.
The returned data is grouped by a 'groupfield' (say for example) - and for each change of 'groupfield' a new WebUserControl is added to a panel on the main web form (having been cleared initially).

Within the WebUserControl I show the appropriate data records for that 'groupfield' and allow the user to update these via textboxes, etc (so an underlying data record could have it's 'field1' / 'field2' values changed) - this is done via SQL and hits the underlying database table.
Following these being updated I want to reload the control and show the newly updated data.

However, given these controls were initially added dynamically to the main web form, as soon as I click a button in one of them (WebUserControls) the main page effectively reloads and the added WebUserControls no longer exist. So the update / reload from the button (in the WebUserControl) being clicked do not get run.

How can I get around this?
I want to allow the user to make entries in the WebUserControl(s) and then click a button in the same WebUserControl(s) for the data to be updated and the contents of the control to be reloaded / refreshed.
How do I do this?

Any help would be appreciated.
I've been tearing my hair out all day...

Thanks in advance.
Steve
 
You have to recreate the controls each time the page loads. Do this in the Page_Init event.
 
So when I first set up the series of WebUserControls should I store these (or details to recreate these) in an ArrayList/Hastable to then rebuild on the web form via the Page_Init?
 
When you add a control to your page, dynamically, this should be done in the page_init.
 
The controls are dynamically added to the page based on the user search selection as made - ie. name / pack size of item.
So each new search would spawn a new set of WebUserControls on the web form according to the data reviewed.

Could the Page_Init still be used for a situation like this?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top