如何使用Enterprise Library 5.0填充下拉列表

时间:2011-01-18 16:40:39

标签: asp.net enterprise-library daab data-access-app-block

是否有使用Enterprise Library 5.0 DAAB填充下拉框的简单代码?

我试过这个,但它不起作用:

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

2 个答案:

答案 0 :(得分: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();

答案 1 :(得分:0)

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