I am trying to change the image url of an image control based on condition inside gridview below is my markup:
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# IIf(CDate(Eval("startdate")) < CDate(Eval("expdate")),"~/iWebmallManager/Images/bullet_red.png",
"~/iWebmallManager/Images/bullet_green.png" %>'
/>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
The IIf statement didn’t work. i dont know what I am doing right please help
You should do that in codebehind, since it increases the readability and is easier to debug: