I've seen one other post on this, but it was related to using datagrid. I'm not using a datagrid; I am using labels with the visibility property set to true or false based on what is set in my SelectedIndexChanged method.
It's a pretty typical setup: I have country, province and state dropdowns populated with a SQLdataReader. When the page first loads, "Country" and "State" only are displayed, and both of these dd's are set to "select..."
Now, I'm having problems with subsequent changes to that country dd. Basically, the FIRST time I select either "Canada" or "United States, the Province or State dd displays as appropriate. However, any subsequent selection of Canada or U.S. only displays the country dd, no province OR state.
I'm sure I'm missing something completely obvious and I'll feel like a dolt, but can someone take a look and see what I'm doing wrong? I do have autoeventwireup=true, and the dd is set to autopostback. Is there something else I need to check in the page_load event now?
The form fields in question:
Country
"country" runat="server" OnSelectedIndexChanged="country_SelectedIndexChanged" AutoPostBack="true">
"StateRow" runat="server" Visible="true">
State
"state" runat="server">
"ProvinceRow" runat="server" Visible="false">
Province
"ProvinceDD" runat="server">
The event:
void country_SelectedIndexChanged(object sender, EventArgs e)
{
if (country.SelectedValue == "USA")
{
StateRow.Visible = true;
ProvinceRow.Visible = false;
}
else if (country.SelectedValue == "CAN")
{
StateRow.Visible = false;
ProvinceRow.Visible = true;
}
else
{
StateRow.Visible = false;
ProvinceRow.Visible = false;
}
}