I have a column in a band in a WHDG that is bound to a boolean field. When the value of the boolean is true I want to show one image and when the value of the boolean is false I want to show no image or another image.
Is this possible with WHDG?
Hi dvanmil,
This would be accomplished the same way it is done in the WebDataGrid. There are three options. You can handle initialize row event and then set the text of the cell to an <img /> tag and turn HtmlEncode off for that column. You could make the field a template column and conditionally set the image src based upon that value. Or you could use the format field off of that column. And coming in 11.1, there will be a bound check box field. And you could actually set a custom image for checked/unchecked (true/false). One of these should get you going.
regards,
David Young
Thanks for the reply.
I currently have the following code:
<Columns>
<ig:TemplateDataField Key="UrgencyField"> <ItemTemplate> <asp:Image runat="server" ID="UrgencyImage" /> </ItemTemplate> </ig:TemplateDataField>
</Columns>
How would I set the imageurl here conditionally, assuming the field I bind to is called Urgency?
Hi,
Try the folllowing code in the code behind.
public string ImageSrc(bool b)
{
return b ? "one.jpg" : "two.png";
}
And the following column.
<ig:TemplateDataField Key="TemplateField_0">
<Header Text="TemplateField_0" />
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl=<%# ImageSrc((bool)DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "IsActive"))%> />
</ItemTemplate>
</ig:TemplateDataField>
That should display one image for true and another for false.
-Dave