DropDownList的數據綁定!
<>
public void PageLoad(object sender,EventArgs e)
{
if(!IsPostBack)
{
SqlConnection myConn = new SqlConnection(server="";database="";user id="";pwd="");
SqlDataAdapter da = new SqlDataAdapter("select a,b from table",myConn);
DataSet ds = new DataSet();
da.Fill(ds,"table");
this.DropDownList.DataSource=this.ds.tables["table"].DefaultView;
this.DropDownList.DataTextField="a";
this.DropDownList.DataValueField="b";
this.ddl_dept.DataBind();
}
}
阅读(2944) | 评论(4) | 转发(0) |