0

我有一个类(称为 A),它有另一个类作为字段(称为 B) B 类中有属性 attr。

如果我们将 dropwdownList 的 Datasource 设置为 A 类,我们如何将 dropdownlist datavaluefield 设置为 B.attr?

4

1 回答 1

1

在 A 上公开一个属性以获取 B 中的属性值。据我所知,这不是直接可能的(使用实例作为属性)

public class A
{
   public string BAttrValue
   {
      get {

         return this.B.Atrr;
      }
   }
}

您可以将 绑定BAttrValue到您的下拉列表

于 2013-07-22T11:11:29.940 回答