简体   繁体   中英

How to Populate a dropdown using Enterprise Library 5.0

Is there a simple code to populate a dropdown box using Enterprise Library 5.0 DAAB?

I've tried this, but it is not working:

cmbOffice.DataSource = _db.ExecuteDataSet(
      CommandType.Text,
      "select office_id, office_name from office").Tables[0]; 
cmbOffice.DataBind();
DataSet ds = _db.ExecuteDataSet(
    CommandType.Text,
    "select office_id, office_name from office"); 

cmbOffice.DataSource = ds;
cmbOffice.DataValueField= "office_id";
cmbOffice.DataTextField = "office_name";

cmbOffice.DataBind();

cmbOffice.DataSource = _db.ExecuteDataSet(CommandType.Text,"select office_id, office_name from office").Tables[0].defaultView;
cmbOffice.DataBind();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM