DropDownList1.DataBind();  //绑定数据库中一组值 假如第一个为 aaa
this.DropDownList1.Items.Insert(0, "实时");
yhlb=this.DropDownList1.SelectedItem.Text; 为什么 yhlb=aaa 而不是"实时"呢 要想让 实时 和其他记录一样由selectedItem得来该怎么办

解决方案 »

  1.   

    this.DropDownList1.Items.Insert(0, "实时");
    ------------------
    这样插入数据,就把它放在首行了,原来的首行aaa被挤到第2行,但选定的还是它.所以你取到的还是它.
    如果你想取新插入的项,你必须这样
    this.DropDownList1.Items[0].Text;
      

  2.   

    可以在this.DropDownList1.Items.Insert(0, "实时");
    下面写this.DropDownList1.Selected.Item.text="实时"
      

  3.   

    private void bind1()   //对年份控件进行绑定
    {
    if(flag=="a")
    {
    wlriqi();
    this.DropDownList1.Items.Insert(0, new ListItem("实时"));
    this.DropDownList1.SelectedItem.Text="实时";

    }
    else
    {
    wlriqi();
    }
    return;
    }