古詩詞大全網 - 成語解釋 - DropDownList的DataTextField屬性我想要綁定多個值

DropDownList的DataTextField屬性我想要綁定多個值

假設妳從SQL讀取的數據存在DataTable 中 由 detData()取得數據

DataTable dt =getData();

DropDownList ddl = new DropDownList();

ddl.DataSource= dt;

ddl.DataTextField = "a";

ddl.DataValueField = "a";

ddl.DataBind();