I have a DropDownList on a repeater control, as well as a button.
The button is disabled until a valid item is selected on the DropDownList, when I want to enable the button. Unfortunately I can't seem to get to it.
Found the repeater by: (.As() method is an extension method for (object as T), just makes casting easier)
sender.As<Control>().NamingContainer.Parent.As<Repeater>()
However the Repeater I get back doesn't help me as the FindControl(string name) function isn't returning anything – and shows nothing useful in the watch window.
So, how can I get a sibling control (an ImageButton in this case) on a repeater from an event of another item on the repeater (DropDown_SelectedIndexChanged in this case)?
EDIT
I finally worked out
sender.As<ImageButton>().NamingContainer.As<RepeaterItem>().FindControl("ControlName")
Best Answer
I think i have the answer for your question:
1.-I create a repeater with the dropdownlist and button to do the tests:
I databind the repeater.
2.-I create the method DropDownList1_SelectedIndexChanged:
The way to do it is to ask to the control, who is its Parent, that's to say, the RepeaterItem, or you can use NamingContainer (as I have written finally) and there you can ask about any control that is inside.