title: VB ItemTemplate DataBinder.Eval Container.DataItem in C#
body: <p>This is the HTML in the VB project that is being ported to a new C# app:</p>
  
  <pre><code>&lt;asp:DataGrid id="DG1" runat="server" HorizontalAlign="center" AutoGenerateColumns="False" width="850" AllowSorting="True" OnSortCommand="LawSortEvent" ShowFooter="true" onItemDataBound="LawDG_ItemDataBound" FooterStyle-Font-Bold="True" &gt;
    &lt;Columns&gt;
    &lt;asp:BoundColumn DataField="ID" HeaderText="" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" /&gt;
    &lt;asp:BoundColumn DataField="afecategory" SortExpression="afecategory" HeaderText="Code" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" /&gt;
    &lt;asp:BoundColumn DataField="transdate" DataFormatString="{0:MM/dd/yyyy}" SortExpression="transdate" HeaderText="Date" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" /&gt;
    &lt;asp:BoundColumn DataField="company" SortExpression="company" HeaderText="Vendor" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" /&gt;
    &lt;asp:BoundColumn DataField="description" SortExpression="description" HeaderText="Desc" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" /&gt;
    &lt;asp:BoundColumn DataField="systemtype" SortExpression="systemtype" HeaderText="System" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" /&gt;
    &lt;asp:BoundColumn DataField="apinvoice" SortExpression="apinvoice" HeaderText="AP Inv" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" /&gt;
    &lt;asp:BoundColumn DataField="amount" SortExpression="amount" DataFormatString="{0:C}" HeaderText="Total" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right"  /&gt;
      &lt;asp:templatecolumn headertext="" ItemStyle-HorizontalAlign="Center" &gt;
        &lt;itemtemplate&gt;
          &lt;asp:ImageButton id="btnViewInvoice" runat="server"
            ImageURL="/images/glass2.png" 
            OnCommand="dgViewInvoice" 
            CommandArgument='&lt;%# DataBinder.Eval(Container.DataItem, "apinvoice") %&gt;' 
            commandname='&lt;%# DataBinder.Eval(Container.DataItem, "vendornum") %&gt;' 
            AlternateText="View Invoice" 
            Visible='&lt;%# (DataBinder.Eval(Container.DataItem, "systemtype") &lt;&gt; "GL") %&gt;' 
          /&gt;
        &lt;/itemtemplate&gt;
      &lt;/asp:templatecolumn&gt;
    &lt;/Columns&gt;
  &lt;/asp:Datagrid&gt;
  </code></pre>
  
  <p>My issue is with the ImageButton - I don't know how to write that in C#, because I'm not really sure what it is trying to do.</p>
  
  <p>The closest I found to explaining some of this was <a href="http://weblogs.asp.net/rajbk/archive/2004/07/20/what-s-the-deal-with-databinder-eval-and-container-dataitem.aspx" rel="nofollow">What's the deal with Databinder.Eval and Container.DataItem?</a>, but I've been trying different ways of changing my text to make this work for the last 30 minutes with no success.</p>
  
  <p>Everytime I change the text, the error message changes to what I tried to do differently.</p>