you can like this:eg:
<asp:DropDownList id="ddlCountry" DataSource="<%# BindTheCountry() %>"  DataTextField="Country" DataValueField="Country" runat="server" />public SqlDataReader BindTheCountry()
{
SqlConnection objConn=new SqlConnection("server=data;uid=run1;pwd=benben;database=Northwind");
SqlCommand cmdCustomers=new SqlCommand("SELECT Distinct Country FROM Customers",objConn);
cmdCustomers.CommandType=CommandType.Text;
objConn.Open();
return (cmdCustomers.ExecuteReader(CommandBehavior.CloseConnection));
}

解决方案 »

  1.   

    DropDownList1.DataTextField="name";
    DropDownList1.DataValueField="id";
    绑定数据库的一个字段.name
    protected void Select_Changded(object sender,EventArgs e)
    {
                 Textbox1.Text=DropDownList1.SelectedItem.Text;
    }
      

  2.   


    SqlConnection Connection=new SqlConnection(.....);
    Connection.Open();
    SqlCommand myCommand=new SqlCommand("selectName",Connection);
    myCommand.CommandType=CommandType.StoredProcedure;
    myCommand.ExecuteNonQuery();
    SqlDataAdapter sda=new SqlDataAdapter();
    sda.SelectCommand=myCommand;
    DataSet ds=new DataSet();
    sda.Fill(ds,"em");

    Connection.Dispose();
    DropDownList1.DataSource=ds;
    DropDownList1.DataTextField="name";
    DropDownList1.DataValueField="id";
    DropDownList1.DataBind();
      

  3.   

    各位大哥,我還是不是很明白,我的各個item項是從前台添加的,所以,我還是實現不了.
      

  4.   

    你从数据库读出数据以后
    先建立一个listitem
    ListItem li = new ListItem();
    然后用你的值设置li的text和value属性
    然后调用DropDownList.Items.Add(li);不知道理解对了没有……
      

  5.   

    先从数据库取出数据,然后绑定
    DropDownList1.DataTextField="name";
    DropDownList1.DataValueField="id";
    DropDownList1.DataBind()ListItem li = new ListItem("Text","Value");
    DropDownList.Items.Add(li);
    ~~~~~