I have a gridview which has a checkbox column and an image column
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.
the .aspx page has
<asp:TemplateField HeaderText="Backup Session Status"
SortExpression="backupsessionstatus">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
Checked='<%# Bind("backupsessionstatus") %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server"
Checked='<%# Bind("backupsessionstatus") %>' Enabled="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Backup Session Status">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
and the .cs file is:
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";
}
}
it is not displaying no image in the column
please suggest a way... thanks