如何把数据库里的数据导入DropDownList中!

解决方案 »

  1.   

    DropDownList2.DataSource=SqlHelper.ExecuteDataset(sqlconnstring,CommandType.Text,"select * from 品牌 order by 品牌").Tables[0];
    DropDownList2.DataTextField="品牌";
                DropDownList2.DataValueField="ID";
    DropDownList2.DataBind();
    DropDownList2.Items.Insert(0,new ListItem("选择品牌..",String.Empty));
      

  2.   

    DropDownList2.DataSource = dataTable1;
    DropDownList2.DataTextField = "XXX"or foreach(DataRow r in dataTable1.Rows)
    {
       DropDownList2.Items.Add(r["XXX"].ToString());
    }
      

  3.   

    DropDownList.DataSource = dataTable1;
    DropDownList.DataTextField = "列名"   //DropDownList的显示值
    DropDownList.DataValueField = "列名"  //DropDownList的value值ok