The sender parameter is an object, you need to cast it appropriately.
In the case of a DropDownList.SelectedIndexChanged event, the sender parameter is the DropDownList that the used selected a value from. This is not in any way related to which button he clicked to load the dropdown in the first place!
If you need to know which button was clicked, then in the ButtonClick event, cast the
to a Button, and insert it as the Tag property of the dropdown:
Button b = sender as Button;
if (b != null)
myDropDownList.Tag = b;
Then check the tag in the SelectedIndexChanged Event:
Button b = myDropDownList.Tag as Button;
if (b == myButton1)
"can i understand what is Tag ??"
property is a an
variable which is available in all controls, for you to add your own information as required. For example, you might set the Tag of a textbox to the Database row ID that the textbox content came from: then you can update the correct row without having to look elsewhere.
Because it is an
variable, and everything is derived from
you can put anything you like in there: a Button, a string, a Form, even a class you defined. All you have to do is cast it appropriately and use it when you want.