一个用来修改用户信息的页面,上一个页面把用户名传过来,再根据用户名查询相关的信息,其中部门这个字段是用对应部门的代码表示,页面中部门用DropDownList来表示,现在要求页面初始化时DropDownList相对应的选项被选中,如,张三为人事部,则页面初始化时 部门这个DropDownList选中人事部

解决方案 »

  1.   

    先绑定(填充)YourDropDwonList
    然后
    YourDropDwonList.Items.FindByValue("xxxx").Selected = true;
      

  2.   

    楼上的还漏了, 要先将DropDownList的SelectedIndex设为-1, 再设selected
    应为当有两个item被设为selected会引发异常
      

  3.   

    SelectedItem 下面 没有FindByValue 怎么回事?
      

  4.   

    SelectedItem 是一个item 他当然没有findbyvalue了 item集合才有了
      

  5.   

    YourDropDwonList.Items.FindByValue("xxxx").Selected = true;
    是这样写呀 看清楚 Items.FindByValue