我的页面里放了一个DropDownList,是用数据绑定的,我想给DropDownList添加一个用户未选择项,不知如何添加。我的DropDownList数据是这样绑定的: 
             DataTable xf = tbmyclass.szfh_username();
            this.DropDownList9.DataSource = xf;
            this.DropDownList9.DataTextField = xf.Columns["szfh"].ColumnName;
            this.DropDownList9.DataValueField = xf.Columns["szfh"].ColumnName;
            this.DropDownList9.DataBind();
这样可以绑定数据,但是不知道如何在添加一个用户未选择项,本人是新手,希望高手指点一下,谢谢。

解决方案 »

  1.   

    DropDownList9.Items.Insert(0,new ListItem("==请选择==",""));
      

  2.   


                ListItem item = new ListItem("未选择");
                DropDownList1.Items.Add(item);
      

  3.   

    设置DropDownList属性 AppendDataBoundItems="True",然后在DropDownList标签内嵌入<asp:ListItem Value="">--请选择--</asp:ListItem>
      

  4.   

    DataTable xf 里头 在 0行插入一个 未选择
      

  5.   


    DataRow dr = xf.NewRow();
    dr["szfh"] = "未选择";
    xf.Rows.InsertAt(dr,0);
    大致是这样自己试验一下
      

  6.   

    当然可以
    ddlist.DataSource=ds;
    ddlist.DataValueField="id";
    ddlist.DataTextField="name";
    ddlist.DataBind();
    ddlist.Items.Insert(0,new ListItem("==请选择==",""));
      

  7.   

    在DataTable表中添加一项未选择,应该如何添加?
      

  8.   


    谢谢,按照FlashElf的方法解决了,非常感谢FlashElf,也非常感谢您关注我的问题。