DropDownList指定的是DataTextField 和DataValueField ,然后需要DataBind();下面是一个取得数据源后绑定的例子,作下参考
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "food_name";
DropDownList1.DataValueField = "food_id";
DropDownList1.DataBind();

解决方案 »

  1.   

    DropDownList指定的是DataTextField 和DataValueField ,然后需要DataBind();
    DropDownList的数据源最好用SqlDataReader
    DropDownList1.DataSource = ds;
    DropDownList1.DataTextField = 字段名//邦定DropDrowList中Item显示的文本
    DropDownList1.DataValueField = 字段名//邦定DropDrowList中Item的值
    DropDownList1.DataBind();
      

  2.   

    SqlConnection cn=new SqlConnection(ConnectionString);
    SqlDataAdapter dat=new SqlDataAdapter(cmdStr,cn);
    DataSet dst=new DataSet();
    dat.Fill(dst);
    DropDownList1.DataSource = dst;
    DropDownList1.DataTextField = 表字段名
    DropDownList1.DataValueField = 表字段名
    DropDownList1.DataBind();
      

  3.   

    DropDownList指定的是DataTextField 和DataValueField ,然后需要DataBind();下面是一个取得数据源后绑定的例子,作下参考
    DropDownList1.DataSource = dt;
    DropDownList1.DataTextField = "food_name";
    DropDownList1.DataValueField = "food_id";
    DropDownList1.DataBind();
      

  4.   

    lijia4() ( ) 信誉:100    Blog   加为好友  2007-05-30 11:58:32  得分: 0  
     
     
       SqlConnection cn=new SqlConnection(ConnectionString);
    SqlDataAdapter dat=new SqlDataAdapter(cmdStr,cn);
    DataSet dst=new DataSet();
    dat.Fill(dst);
    DropDownList1.DataSource = dst;
    DropDownList1.DataTextField = 表字段名
    DropDownList1.DataValueField = 表字段名
    DropDownList1.DataBind();
      
     
    正解!