---------------------------------------------------------------------------
Put this code in .aspx file
---------------------------------------------------------------------------
<asp:TemplateField HeaderText="|| Status ||">
<ItemTemplate>
<asp:Image ID="imgGreenAct" ImageUrl='<%# GetImage(Convert.ToString(DataBinder.Eval(Container.DataItem, "Status")))%>' AlternateText='<%# Bind("Status") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
---------------------------------------------------------------------------
Put this code in .aspx.cs file
---------------------------------------------------------------------------
public string GetImage(string status) { if (status=="Active")
return "~/images/green_acti.png";
else
return "~/images/red_acti.png";
}
Put this code in .aspx file
---------------------------------------------------------------------------
<asp:TemplateField HeaderText="|| Status ||">
<ItemTemplate>
<asp:Image ID="imgGreenAct" ImageUrl='<%# GetImage(Convert.ToString(DataBinder.Eval(Container.DataItem, "Status")))%>' AlternateText='<%# Bind("Status") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
---------------------------------------------------------------------------
Put this code in .aspx.cs file
---------------------------------------------------------------------------
public string GetImage(string status) { if (status=="Active")
return "~/images/green_acti.png";
else
return "~/images/red_acti.png";
}
--------------------------------------------------------------------
No comments:
Post a Comment