Dan
Dan

Reputation: 33

Bind Control to SubClass

I have a checkbox that I want to bind to a subclass. The DataSource uses the ParentClass as the business object. Is it possible? Something like:

<asp:CheckBox ID="cb" Text="Test" Checked='<%# Bind("ChildClass.Test") %>' />

public class ParentClass {
   private ChildClass _ChildClass;

   public ChildClass ChildClass {
     get { return _ChildClass; }
     set { _ChildClass = value; }
   }

}

public ChildClass ChildClass {
   private bool _Test;

   public bool Test {
      get { return _Test; }
      Set { _Test = value; }
   }    
}

Upvotes: 0

Views: 329

Answers (1)

Marcie
Marcie

Reputation: 1259

You can use Eval for one-way binding. Two-way binding with Bind is not possible for subclass properties.

Upvotes: 1

Related Questions