I have a DataList control on my page and inside are some dropdownlists. When the first dropdownlist is changed I need to change other dropdowns as well. I have been trying to access these controls like this:
Dim ddl As DropDownList = DirectCast(sender, DropDownList)
Dim dataItem As DataListItem = TryCast(ddl.NamingContainer, DataListItem)
ddlFlokkur = TryCast(dataItem.FindControl("DataList1$ctl00$ddlFlokkur"), DropDownList)
The error I get when I try to work with ddlFlokkur is Object reference not set to an instance of an object.
How can I access dropdownlists in the datalist and work with them ?