views:

1572

answers:

2

Hi,

I've several web user controls on my asp.net page and I wanna pass values between them. For example :

There is a dropDownList in one of them and when user selects any item from dropDownList, it can pass the selected value to the other user control which includes GridView to show related data of selected item value from the user control which contains the dropdownlist. (woow pretty awkward sentence tho)

Thanks and Regards..

P.s : Can we use User controls as class in the way to return values ?

+2  A: 

On the DropDownList onChange event you could then assign the selected item value to the property of the other user control.

Ok, your UserControls should have properties that allow data to be set. For example in Control2 you would have:

public string needData { 
get { return MyData; }
set { 
  MyData = value;
  //do whatever you need to do with that data here
}

Now in your page you would capture the DropDownList OnChange event and inside that you would something like this:

myControl2.needData = myDropDownList.SelectedValue;

Does that make more sense?

Victor
But How ? Could you write some simple code :(
Braveyard
+1  A: 

Use delegates, example here

Hope this helps

MOZILLA