title: display image in gridview column based on value in other column
body: <p>I have a gridview which has a checkbox column and an image column</p>
  
  <p>now if the checkbox is selected the image column should show a green tick image and if checkbox is not checked it should show a wrong image icon in consecutive rows.</p>
  
  <p>the .aspx page has</p>
  
  <pre><code> &lt;asp:TemplateField HeaderText="Backup Session Status" 
               SortExpression="backupsessionstatus"&gt;
               &lt;EditItemTemplate&gt;
                   &lt;asp:CheckBox ID="CheckBox1" runat="server" 
                       Checked='&lt;%# Bind("backupsessionstatus") %&gt;' /&gt;
               &lt;/EditItemTemplate&gt;
               &lt;ItemTemplate&gt;
                   &lt;asp:CheckBox ID="CheckBox1" runat="server" 
                       Checked='&lt;%# Bind("backupsessionstatus") %&gt;' Enabled="false" /&gt;
               &lt;/ItemTemplate&gt;
           &lt;/asp:TemplateField&gt;
  
  
  
           &lt;asp:TemplateField HeaderText="Backup Session Status"&gt;
               &lt;EditItemTemplate&gt;
                   &lt;asp:TextBox ID="TextBox3" runat="server"&gt;&lt;/asp:TextBox&gt;
               &lt;/EditItemTemplate&gt;
               &lt;ItemTemplate&gt;
                   &lt;asp:Image ID="Image1" runat="server"/&gt;
               &lt;/ItemTemplate&gt;
           &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>and the .cs file is:</p>
  
  <pre><code> foreach (GridViewRow myRow in GridView1.Rows)
              {
                  Image img1 = (Image)myRow.FindControl("Image1");
                  CheckBox chkbox1 = (CheckBox)myRow.FindControl("CheckBox1");
                  if (chkbox1.Checked)
                  {
                      img1.ImageUrl = "greenimage.jpg";
                  }
                  else
                  {
                      img1.ImageUrl = "redimage.jpg";
                  }
              }
  </code></pre>
  
  <p>it is not displaying no image in the column</p>
  
  <p>please suggest a way...
  thanks</p>