title: How to bind list inside a list to a GridView in ASP.NET
body: <p>I have a class named Student</p>
  
  <pre><code>public class Student
  {
      public string Name { get; set; }
      public List&lt;int&gt; Marks { get; set; }
      public Student()
      {
      }
  }
  </code></pre>
  
  <p>and I need to bind a list of Student to GridView</p>
  
  <pre><code>        List&lt;Student&gt; StudentList = new List&lt;Student&gt;();
  
          Student stud = new Student();
          stud.Name = "Scott";
          List&lt;int&gt; marks = new List&lt;int&gt;();
          marks.Add(10); 
          marks.Add(20); 
          marks.Add(30);
          stud.Marks = marks;
  
          StudentList.Add(stud);
  
          Student stud1 = new Student();
          stud1.Name = "Jon";
          List&lt;int&gt; marks1 = new List&lt;int&gt;();
          marks1.Add(10);
          marks1.Add(20);
          marks1.Add(30);
          stud1.Marks = marks1;
  
          StudentList.Add(stud1);
  
          GridView1.DataSource = StudentList;
          GridView1.DataBind();
  </code></pre>
  
  <p>The gridview shows the name field only. how I can show the list of marks also with name field. (In this all the students have same number of marks, means sometimes 3, or sometimes 5. etc.) </p>
  
  <p>I need show gridview like this</p>
  
  <pre><code>Name    Mark1  Mark2 Mark3 
  Scott   10     20    30
  Jon     10     20    30
  </code></pre>