Ich benutze eine asp.net formsview in meiner asp.net-Seite und updatepanel. Es hat zwei Vorlagen Insertemplate und EditTemplate. In beiden Vorlagen gibt es eine Dropdown-Liste mit der ID ddlCountry. Ich habe eine Dropdown-Liste mit allen Ländern. Ich zeige das Dropdown-Menü für Staaten, wenn das Land USA ist und die Zeile ausblenden soll, in der das Dropdown-Menü für Staaten angezeigt wird. Wenn das Land nicht US ist. Ich verwende folgenden Code, aber es funktioniert nicht:Versteckte Zeile im Dropdown-Menü ausgewählte Indexänderung
protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e)
{
Control c = (Control)sender;
Control nc = c.NamingContainer;
if (nc.ID == "fvBillTo" && rblShipSelect.SelectedValue == "billing")
{
setShippingAndTaxesDisplay();
DropDownList ddlCountry = c as DropDownList;
if (ddlCountry.SelectedItem != null && ddlCountry.SelectedItem.Value == "001")
{
HtmlGenericControl trState = nc.FindControl("trState") as HtmlGenericControl;
trState.Visible = true;
}
else
{
HtmlGenericControl trState = nc.FindControl("trState") as HtmlGenericControl;
trState.Visible = false; // code stops here
}
}
}