I am struggling with the databinding syntax here. For example I have a data structure like this -
public class Course{
public string CourseName {get;set;}
public string CourseCode {get;set;}
public List<Instructor> InstructorsTeaching{get;set;}
}
public class Instructor{
public string InstructorName{get;set;}
public string InstructorCode{get;set;}
}
Now if I want to bind this List Courses to say a gridview manually, I could do
<asp:TextBox runat="server" ID="tbCourseName" Text='<%# Bind("CourseName")%>'/>
while specifying for edit template of the grid but how do I bind the Instructors teaching property to say a ListBox in the same row, I cant figure out the syntax , here is an exaple of what I tried and failed
<asp:ListBox runat="server" ID="tbInstructors"
DataSource='<%# Eval("InstructorsTeaching") as List<Instructor> %>'>
<asp:ListItem Text='<%# Bind("InstructorCode")%>'
Value='<%# Bind("InstructorName")%>'/>...
<as:ListBox/>
My above code does not work for sure :). Ideally I would like to do this in markup instead of code behind.