I have tried populating the dropdownlist in the code behind but it shows an error "stateID does not exist in the current context". THe dropdownlist is inside the datalist
ASPX:
<asp:DataList runat="server" ID="dataList" OnItemDataBound="dataList_ItemDataBound" RepeatDirection="Vertical">
<ItemTemplate>
<asp:DropDownList ID="stateID" AutoPostBack="true" cssclass="form-input" runat="server"></asp:DropDownList>
<asp:DropDownList ID="cityID" AutoPostBack="true" cssclass="form-input" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:DataList>
CodeBehind:
public void LoadStates() {
stateID.DataTextField = "Name";
stateID.DataValueField = "ID";
}
Error: stateID does not exist in the current context.
