注册 登录
编程论坛 ASP.NET技术论坛

DropDownList关联问题

yxhrgyj 发布于 2012-03-21 09:13, 429 次点击
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        string[] CarArray = new string[4] { "Ford", "Honda", "BMW", "Dodge" };
        string[] AirplaneArray = new string[3] { "Boeing 777", "Boeing 747", "Boeing 737" };
        string[] TrainArray = new string[3] { "Bullet Train", "Amtrack", "Tram" };
        if (DropDownList1.SelectedValue == "Car")
        {
            DropDownList2.DataSource = CarArray;
        }
        else if (DropDownList1.SelectedValue == "Airplane")
        {
            DropDownList2.DataSource = AirplaneArray;
        }
        else
        {
            DropDownList2.DataSource = TrainArray;
        }
        DropDownList2.DataBind();
        DropDownList2.Visible = true;


为什么在改变DropDownList1的内容DropDownlist2的内容没有跟着变
1 回复
#2
yxhrgyj2012-03-21 09:16
解决了。。
1