Ddl_ShuJi.Items.FindByValue(GaChaInfo.ShuJi.ToString()).Selected = true;
Ddl_CunZhang.Items.FindByValue(GaChaInfo.CunZhang.ToString()).Selected = true;
两个DropDownList定位后出现错误,提示如下:Cannot have multiple items selected in a DropDownList. 
然后我去掉Ddl_CunZhang.Items.FindByValue(GaChaInfo.CunZhang.ToString()).Selected = true;
行后就好了。不知???

解决方案 »

  1.   

    同一个DropDownList一次只能又一个选项被选中(或者说不能又多个选项被选中),而你这又两个被选中了,所以会报错。
      

  2.   

    提示已经很清楚了,你创建的DropDownList中有相同value的item
      

  3.   

    在DropDownList中尽量不要出现相同Value字段或者Text字段。否则就会出现上述问题。
      

  4.   

    我这是两个DropDownList,名字也不一样阿各自定位各自的,而其DropDownList里的数据ID 也没有重复。
      

  5.   

    在FindBy前面加一句DropDownList名字.ClearSelection(); 
      

  6.   


    Ddl_ShuJi.ClearSelection(); 
    Ddl_ShuJi.Items.FindByValue(GaChaInfo.ShuJi.ToString()).Selected = true; 
    Ddl_CunZhang.ClearSelection(); 
    Ddl_CunZhang.Items.FindByValue(GaChaInfo.CunZhang.ToString()).Selected = true; 这样子就好了,或者你不要用FindByValue,用FindByText也行的
    原因很简单,当你使用 Ddl_ShuJi.Items.FindByValue(GaChaInfo.ShuJi.ToString()).Selected = true;
    这种形式指定某个item的Selected为true时,之前已经选择的item的Selected值仍然为true
    而DropDownList是不允许多个值被同时选定的,所以会报错
      

  7.   

    Ddl_CunZhang.Items.FindByValue(GaChaInfo.CunZhang.ToString()).Selected = true; Ddl_CunZhang的选项里有重复的Value。