Reference one control from another control while within a Repeater (or DataGrid)
I have a dropdownlist (aka drop down list) box within a repeater. When the index change event fires, I want to make some changes in another control. The problem in doing this was that I could not figure out how I could reference another control. Well, thanks to Scott Mitchell's articles on the datagrid, I was able to figure this out. First, all my repeater elements were editable, so everything was setup within an ItemTemplate column. This only caused me issues in my thinking about it, not in my doing. So, within my SelectedIndexChanged event, I have the following code:
Dim ddl1 as DropDownList = CType(sender, DropDownList)
Dim rpItem as RepeaterItem = CType(ddl1.Parent, RepeaterItem)
Dim ddl2 as DropDownList = CType(rpItem.FindControl("ddl2"), DropDownList)
Now, I have the reference to the second control.
One question, since FindControl() is fairly CPU intensive, is there a better way to do this?