title: Bind Gridview Datasource with Linq (asp.net)
body: <p>Basically, what I want to do is to bind a Linq query to the datasource of a gridview. Here is my code so far :</p>
  
  <pre><code>ddgDossiers.DataSource = (From c In dbConnection.Campaigns.AsQueryable Select c).ToList
  ddgDossiers.DataBind()
  </code></pre>
  
  <p>It compiles and doesn't complain of anything.</p>
  
  <pre><code>&lt;asp:GridView ID="ddgDossiers" runat="server" CellPadding="0" CellSpacing="0" AllowSorting="True"
  AutoGenerateColumns="False" EnableViewState="True" AllowPaging="True" PageSize="35"
  PagerStyle-HorizontalAlign="Right" PagerStyle-Mode="NumericPages" PagerStyle-Position="TopAndBottom"
  BorderWidth="1" GridLines="Both" BorderColor="#000000" CssClass="mGrid" PagerStyle-CssClass="pgr"&gt;
  &lt;PagerSettings Position="TopAndBottom" /&gt;
  &lt;Columns&gt;
      &lt;asp:TemplateField Visible="false" HeaderText="UniqueID" ItemStyle-HorizontalAlign="left"
          HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="1%" HeaderStyle-Width="1%"
          HeaderStyle-CssClass="GridTitle" ItemStyle-CssClass="rowReport" SortExpression="UniqueId"&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:Label ID="lblUniqueID" runat="server" Text='&lt;%#Container.DataItem("Campaign.CampaignId").ToString%&gt;' /&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
  &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>The error is pointing on this line :</p>
  
  <pre><code>&lt;asp:Label ID="lblUniqueID" runat="server" Text='&lt;%#Container.DataItem("CampaignId").ToString%&gt;' /&gt;
  </code></pre>
  
  <p>And saying : No default member found for type 'Campaign'.</p>
  
  <p>Is there anything to do with that? Thanks in advance.</p>