两个dropdownlist,第一个dropdownlist里面是省,第二关是相应的城市,如下代码:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (DropDownList1.SelectedValue)
{
case "河北":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("石家庄");
DropDownList2.Items.Add("保定");
break;
case "山东":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("青岛");
DropDownList2.Items.Add("日照");
break;
case "四川":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("成都");
DropDownList2.Items.Add("绵阳");
break;
}
}
在选择省时为什么第二个没有反应(不会显示相应的城市)?急死了,弄了一天了,请帮忙。
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (DropDownList1.SelectedValue)
{
case "河北":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("石家庄");
DropDownList2.Items.Add("保定");
break;
case "山东":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("青岛");
DropDownList2.Items.Add("日照");
break;
case "四川":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("成都");
DropDownList2.Items.Add("绵阳");
break;
}
}
在选择省时为什么第二个没有反应(不会显示相应的城市)?急死了,弄了一天了,请帮忙。
代码是否执行,看看DropDownList1.SelectedValue值
DropDownList1.Items.Add(new ListItem("text","value"));
DropDownList1.Items.Add(new ListItem("text","value"));
加在哪里?(新手请您详指)