I am struggling with data binding 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 Courses list to say gridview manually, I could do
<asp:TextBox runat="server" ID="tbCourseName" Text='<%# Bind("CourseName")%>'/>
specifying for the grid editing template, but how can I bind the instructors training property to say ListBox on the same line, I can not determine the syntax, here is an example of what I tried and could not
<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 doesn't work for sure :). Ideally, I would like to do this in markup instead of code.
source
share