【问题标题】:How to Populate a dropdown using Enterprise Library 5.0如何使用 Enterprise Library 5.0 填充下拉列表
【发布时间】:2011-06-11 05:24:44
【问题描述】:

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

我已经试过了,但它不起作用:

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

【问题讨论】:

  • 让我们试着让你的问题变得更好。企业库是不同用途的应用程序块的集合,你想做什么?您当前的问题只适合关闭 - 不是真正的问题。
  • 我想使用 Enterprise Library 填充下拉框
  • cmbOffice.DataSource = _db.ExecuteDataSet(CommandType.Text,"select office_id, office_name from office").Tables[0]; cmbOffice.DataBind();我试过这个。不工作。
  • 我不是来打发时间的。试图解决一个问题。您能否尝试理解我的问题,而不是说“您当前的问题只适合关闭 - 不是真正的问题”
  • @Vivek 我相信语言障碍会导致双向问题。企业库包含许多部分。在不知道您在谈论哪一部分的情况下,没有人可以提供错误。我猜你希望使用 DAAB。使用此信息更新您的问题。

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


【解决方案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();

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-19
      • 2017-08-05
      • 2020-04-08
      • 1970-01-01
      • 1970-01-01
      • 2023-04-04
      • 2016-11-30
      • 1970-01-01
      相关资源
      最近更新 更多