b

html:

 

  省份<asp:DropDownList ID="dropProvince"
            runat="server" AutoPostBack="True"
            onselectedindexchanged="dropProvince_SelectedIndexChanged">
            <asp:ListItem Text="湖南" Value="1"></asp:ListItem>
            <asp:ListItem Text="湖北" Value="2"></asp:ListItem>
        </asp:DropDownList>
        城市<asp:DropDownList ID="dropCity" runat="server">
        </asp:DropDownList>

 

后台代码:

加一个方法

   protected void dropProvince_SelectedIndexChanged(object sender, EventArgs e)
        {
            dropCity.Items.Clear();
            if (dropProvince.SelectedValue == "1")
            {
                dropCity.Items.Add(new ListItem { Text = "长沙", Value = "1" });
                dropCity.Items.Add(new ListItem { Text = "株洲", Value = "2" });
            }
            else if (dropProvince.SelectedValue == "2")
            {
                dropCity.Items.Add(new ListItem { Text = "武昌", Value = "3" });
                dropCity.Items.Add(new ListItem { Text = "汉口", Value = "4" });
            }
        }

你可能感兴趣的:(B)