我有两个dropdownlist,都是显示1到24的数字,直接写到里面的.我现在想如果第一个选择8的话,第二个就不能选择8和8以前的数字,请大家指教

解决方案 »

  1.   

    如果服务器控件做的话,很简单啊.
    第一个ddl设置为AutoPostBack="True",然后在SelectedIndexChanged事件里面绑定第二个ddl
    for(int i = this.dropdownlist1.SelectedValue;i<24;i++)
    {
      //这个添加dropdownlist1的项
    }
      

  2.   

    可以用javascript编写一个;如果是服务器控件只需要添加一个事件就可以了
      

  3.   

    先把两个都加上同样的项
    把第一个的AutoPostBack设为true在事件中判断,如果第一个选了删除第二个里面的项:
    dropdownlist2.Items.RemoveAt(dropdownlist1.selecteditem.vale);
      

  4.   

    根据第一个dropdownlist的SelectedIndexChanged事件
    将第一个dropdownlist的SelectedValue的值或者SelectedItem作为查询的对象传给DropDownList2,
    DropDownList2根据值再绑定
    把第一个的AutoPostBack设为true
      

  5.   

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int sValue = int.Parse(this.DropDownList1.SelectedValue);
            int s2Value;
            for (int i = 0; i < this.DropDownList2.Items.Count;i++ )
            {
                s2Value = int.Parse(this.DropDownList2.Items[i].Value);
                if (s2Value <= sValue)
                {
                    this.DropDownList2.Items[i].Enabled = false;
                }
            }
        }
      

  6.   

    不是我懒,是真的没有找到解决办法,你最后的代码中的item的enabled属性根本就没有!
      

  7.   

    如果没有,那就把第二个dropdownlist 的 item清掉,
    自己增加小于第一个seletedvalue的item