title: How Change in CodeBehind HeaderImage in GridView
body: <p>How to dynamically change the image that is in the header?</p>
  
  <p>The idea is to do it when the grid is created in the "ItemDataBound" event</p>
  
  <p>This is my Grid</p>
  
  <pre><code>&lt;asp:DataGrid ID="dgMain" runat="server" GridLines="Horizontal" AutoGenerateColumns="False" AllowPaging="false"&gt;
  &lt;Columns&gt;
      &lt;asp:BoundColumn DataField="PId" Visible="false" /&gt;
      &lt;asp:TemplateColumn HeaderStyle-Width="80px" HeaderImageUrl="ico_estadistica_despacho.png"&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:ImageButton ID="btnEst" runat="server" BorderWidth="0" ImageUrl="punto.png" CommandName="EstDesp"/&gt;
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateColumn&gt;
      &lt;asp:BoundColumn DataField="CotId" Visible="false" /&gt;
  &lt;/Columns&gt;
  &lt;/asp:DataGrid&gt;
  </code></pre>
  
  <p>I tried something, but did not work out.</p>
  
  <pre><code> If e.Item.ItemType = ListItemType.Header Then
          dgMain2.Columns.Item(1).HeaderImageUrl = "/Images/ico_estadistica_despacho_redi.png"
    End If
  </code></pre>