How to Populate a dropdown using Enterprise Library 5.0

847 Views Asked by At

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();
2

There are 2 best solutions below

0
On BEST ANSWER
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();
0
On

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