title: Sharepoint 2010 databinding with list custom columns
body: <p>I have custom SPlist with some fields that I'd like to bind to a repeater inside a visual web part. I can't use a SPDataSource as I have to do some custom stuff with the list before binding.</p>
  
  <p>How do I bind a custom column in this way? When I use Eval on a custom column I get an error</p>
  
  <p>If I do a test with the datasource it works again Eval("HoursOfOperation"):</p>
  
  <pre><code>&lt;SharePoint:SPDataSource runat="server" ID="data" DataSourceMode="List" 
    SelectCommand="&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name='CBC'/&gt;&lt;Value Type='Boolean'&gt;0&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;"&gt;
    &lt;SelectParameters&gt;
        &lt;asp:Parameter Name="WebUrl" DefaultValue="/" /&gt;
        &lt;asp:Parameter Name="ListName" DefaultValue="Locations" /&gt;
    &lt;/SelectParameters&gt;
  &lt;/SharePoint:SPDataSource&gt;
  </code></pre>
  
  <p>But, if I use the following code I get an error <strong>DataBinding: 'Microsoft.SharePoint.SPListItem' does not contain a property with the name 'HoursOfOperation'.</strong></p>
  
  <pre><code>  SPSite site = SPContext.Current.Site;
    SPWeb web = site.RootWeb;
  
    SPQuery query = new SPQuery();
    query.ViewFieldsOnly = true;
    query.Query = string.Concat(
                                  "&lt;Where&gt;&lt;Eq&gt;",
                                      "&lt;FieldRef Name='CBC'/&gt;",
                                      "&lt;Value Type='Boolean'&gt;0&lt;/Value&gt;",
                                  "&lt;/Eq&gt;&lt;/Where&gt;"
                                  );
  
    SPList list = web.Lists["Locations"];
    SPListItemCollection items = list.GetItems(query);
  
    rp.DataSource = list;
    rp.DataBind();
  </code></pre>
  
  <p>What am I missing here?</p>