我放了一个DropDownList1控件,想跟数据库里的一列绑定,请问下面程序怎么实现不了??public void DropDownList1Bind()                             //绑定博友列表
    {        string sqlstr = "select friend from Friend where Uname = '" + Session["Uname"].ToString() + "'";
        SqlDataAdapter da = new SqlDataAdapter(sqlstr, cn);
        DataSet ds = new DataSet();
        da.Fill(ds, "Friend");
        this.DropDownList1.DataSource = ds.Tables["Friend"];
        this.DropDownList1.DataBind();
        cn.Close();    }

解决方案 »

  1.   

                DropDownList1.DataSource = theDataTable;//DataTable
                DropDownList1.DataTextField = "NAME";
                DropDownList1.DataValueField = "ID";
                DropDownList1.DataBind();
      

  2.   

    都制定为friend 字段吧
    DropDownList1.DataTextField = "friend";
    DropDownList1.DataValueField = "friend";
      

  3.   

    正解
    DataTextField 
    DataValueField