문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top