I'd like to have a RadButton whose icon differs between two images depending on the value of the field. I'm not sure if this is the best approach, but I am defaulting to one specific icon and attempting to change it in the _ItemDataBound method. However, I can't seem to figure out how to access the icon from the RadButton:
<ItemTemplate>
<telerik:RadButton RenderMode="Lightweight" ID="Image2"
CommandName="OnCommentToggleHandled" runat="server">
<Icon PrimaryIconUrl='<%# DataBinder.Eval(Container.DataItem, "Dismissed").Equals(true) ? "/App/images/green-check.png" : "/App/images/comment.gif" %>' runat="server"></Icon>
</telerik:RadButton>
</ItemTemplate>
protected void StatusGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem dataBoundItem = e.Item as GridDataItem;
RadButton foo = dataBoundItem["Dismissed"].Controls[1] as RadButton;
if ((dataBoundItem["Important"].Controls[1] as Image).ImageUrl.Contains("green-check.png"))
{
dataBoundItem.BackColor = System.Drawing.Color.LemonChiffon;
}
else if ((dataBoundItem["Dismissed"].Controls[1] as RadButton).PrimaryIconUrl.Contains("blank.gif"))
{
e.Item.CssClass = "rgRow unhandledMessage ";
}
dataBoundItem["Text"].Text = WebUtility.HtmlDecode(dataBoundItem["Text"].Text);
}
}