I am facing an issue with my gridview, specifically with the template field that contains an ASP image server tag. The goal is to display a different image in each row based on the value obtained during databind.
Unfortunately, my attempt to call a JavaScript function called GetImage() and pass the databind value to it has been unsuccessful. Here is a snippet of my code:
<Columns>
<asp:TemplateField HeaderText="<%$Resources:LocalizedText,LabelStatus%>">
<ItemTemplate>
<asp:Image ID="imgStatus" runat="server" CssClass="label" src="GetImage(<%# Eval("Status_value") %>)"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
The JavaScript function I've created looks like this:
function GetImage(value)
{
if (value == 1)
{
return "../Images/act_green.gif";
}
else
{
return "../Images/act_red.gif";
}
}
Can anyone help me identify what might be going wrong here? Any suggestions on how to resolve this issue would be greatly appreciated. Thanks!