DropDownList1 预设了三个值<asp:DropDownList CssClass="STYLE4" ID="DropDownList1" runat="server" Width="138">
<asp:ListItem Value="MORNING">上午</asp:ListItem>
<asp:ListItem Value="MIDDLE">中午</asp:ListItem>
<asp:ListItem Value="NIGHT">晚上</asp:ListItem>
</asp:DropDownList>不绑定时 默认显示的是 “上午”不如现在有一个button 事件触发后,想实现绑定数据库中(数据库中的值也只有“上午,中午,晚上”)的值 “中午”    
DropDownList1 的预设值变为“中午” 

解决方案 »

  1.   

    ListItem item= DropDownList1.Items.FindByText("中午");if(item!=null)
        item.Selected=true;
      

  2.   

    如果你是从数据库中取出来的话,那你页面上给的要和数据库里面的要一样,不能对不上你可以试一下
    DropDownList.Items.FindByText(数据库去出来的值).Selected=true;
    给的值一定是下拉框里面有的,不能会出错
      

  3.   

    DropDownList.Items.FindByText(数据库去出来的值).Selected=true;
      

  4.   

    Page_Load事件里面
    if(!ispostback)
    {
    dropdownlist.selectvalue="上午";
    }按钮事件里面
    dropdownlist.selectvalue="中午";
      

  5.   

    我想大家都漏了一点关键的语句
    dropdownlist.ClearSelection();
    这句话很关键,否则可能会报错
    其作用是为了使dropdownlist一项也不选中
    然后再DropDownList.Items.FindByText(数据库去出来的值).Selected=true;
      

  6.   

    DropDownList.Items.FindByText(数据库去出来的值).Selected=true; 
      

  7.   


    if (this.DropDownList1.Items.FindByValue("取出值") != null)
            this.DropDownList1.SelectedValue = 取出值;