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();
Vivek Chandraprakash
  • 1,165
  • 2
  • 21
  • 54
  • 2
    Let's try to make your question better. Enterprise library is collection of application blocks with different usage, so what you want to do? Your current question is just suitable for Close - Not a real question. – Ladislav Mrnka Jan 18 '11 at 16:45
  • I want to populate a dropdown box using Enterprise Library – Vivek Chandraprakash Jan 18 '11 at 16:52
  • cmbOffice.DataSource = _db.ExecuteDataSet(CommandType.Text,"select office_id, office_name from office").Tables[0]; cmbOffice.DataBind(); i tried this. not working. – Vivek Chandraprakash Jan 18 '11 at 16:54
  • I'm not here for time pass. Trying to solve a problem. Can you try to understand my problem instead of saying "Your current question is just suitable for Close - Not a real question" – Vivek Chandraprakash Jan 18 '11 at 16:56
  • @Vivek the language barrier is causing an issue both ways, I believe. The Enterprise Library contains many parts. Without knowing which part you are talking about, no person can provide an error. I gather you wish to use the DAAB. Updating your question with this information. –  Jan 18 '11 at 17:02

2 Answers2

1
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();
Randy Levy
  • 22,566
  • 4
  • 68
  • 94
0

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

Vivek Chandraprakash
  • 1,165
  • 2
  • 21
  • 54