为什么不能达到预期的效里呢?

来源:百度知道 编辑:UC知道 时间:2024/06/23 21:44:58
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
switch (DropDownList1.SelectedValue)
{
case "河北":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("石家庄");
DropDownList2.Items.Add("沦州");
DropDownList2.Items.Add("保定");
break;
case"山东":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("济南");
DropDownList2.Items.Add("青岛");
DropDownList2.Items.Add("滩坊");
break;
case"四川":
DropDownList2.Items.Clear();
DropDownList2.Items.Add("成都");
DropDownList2.Items.Add("绵阳");
DropDownLi

switch (DropDownList1.SelectedValue)
这儿SelectedValue是什么,设个断点看看。
还是应该用SelectedItem.Text或者直接用text才是你要的河北等值

你启用了,autopost属性了没有啊,如果没有就没效果

检查autopostback是否为true

如果没有猜错的话,你的DropDownList1.SelectedValue是数字,而不是文字。如果你想获取被选择的项目的文本,请使用DropDownList1.SelectedItem.Text。