title: asp:LinqDataSource DataTable
body: <p>I have a DataTable that I fill manually, ie, </p>
  
  <pre><code>newrow = dt.NewRow();
  dt.Rows.Add(newrow);
  </code></pre>
  
  <p>and Im trying to benefit from the <code>groupby</code> features of <code>LinqDataSource</code> (<a href="http://mattberseth.com/blog/2008/01/building_a_grouping_grid_with.html" rel="nofollow">as shown by Matt</a>) by linking the <code>LinqDataSource</code> to the <code>DataTable</code>, but its just not happening.</p>
  
  <p>Has anyone any experience with this?</p>
  
  <pre><code> &lt;%@ Page Language="C#" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;script runat="server"&gt;
      public class MyData
      {
          public MyData(){}
  
          private DataTable dt = new DataTable("dt");
          public DataTable MyTable
          {
              get { return dt; }
              set { dt = value; }
          }
      }
      protected void Page_Load(object sender, EventArgs e)
      {
          MyData mydata = new MyData();
          mydata.MyTable.Columns.Add("column1");
          DataRow dr = mydata.MyTable.NewRow();
          dr[0] = "some data";
          mydata.MyTable.Rows.Add(dr);
      }
  &lt;/script&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;asp:LinqDataSource 
              ID="LinqDataSource1" 
              runat="server"
              ContextTypeName="MyData" 
              TableName="MyTable"&gt;
          &lt;/asp:LinqDataSource&gt;
  
          &lt;asp:GridView ID="GridView1" runat="server" DataSourceID="LinqDataSource1"&gt;
          &lt;/asp:GridView&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>