How to share data between two controls

G

Guest

Hi!



I have a big big problem!!!

:(



what I will do:



on my web form: UpdateFacility.aspx



are two controls: SearchFacility.ascx and AddEditFacility.ascx



SearchFacility has a dropdown list. when the user choose an item from the
dropdown list the SearchFacility should transfer the selected item value to
a text box on the second control (AddEditFacility).



I try it so:



I set:

ViewState.Add("currentFacilityOID", _ddlFacilities.SelectedItem.Value);



On the InitializeComponent() in AddEditFacility is
ViewState["currentFacilityOID"] ever null.

It seems that on this web form are 3 different ViewStates:



1. ViewState on the UpdateFacility.aspx

2. ViewState on the SearchFacility.ascx

3. ViewState on the AddEditFacility.ascx´



But why?



One possibility that I see is to make this:

Application.Add("currentFacilityOID", _ddlFacilities.SelectedItem.Value);

But I don't want to use the Application object.





Exists any possibility to share data between two controls on the same web
form????







Best Regards,





gicio
 
K

kelly leahy

Exists any possibility to share data between two controls on the same web
form????

What about adding a hidden element to the form and using
it to share the info?

Just make an <INPUT TYPE=HIDDEN ID="someID"></INPUT>.

On the postback, you can refer to it with Request.Form
["someID"] to get the value.

Kelly
 
E

Eran Amitai

All you need to do is handle the SelectedIndexChanged event of the
SearchFacility dropdown and in the handler set the edit box value.
EditBox.Text = DropList.SelectedValue.
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top