I'm using GridImageColumn in to display a icon if the value in the table is false.
Please find the aspx code below.
<
Telerik:RadGrid ID="TelerikThread" Width="97%" AllowSorting="True" PageSize="15"
OnItemDataBound="TelerikThread_ItemDataBound" AllowPaging="True"
AllowMultiRowSelection="True" runat="server" Gridlines="None">
<MasterTableView Width="100%" Summary="RadGrid table" AutoGenerateColumns="false" >
<PagerStyle Mode="NextPrevAndNumeric" />
<Columns>
<Telerik:GridImageColumn UniqueName="GridImageColumn" SortExpression="HasRead"
HeaderText="Unread" DataImageUrlFields="HasRead">
</Telerik:GridImageColumn>
Please find the aspx.cs code below
protected void TelerikThread_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item.DataItem;
TableCell flag = (TableCell)item["HasRead"];
if (flag.Text == "false")
{
System.Web.UI.WebControls.
Image img = (System.Web.UI.WebControls.Image)item["GridImageColumn"].Controls[0];
img.ImageUrl =
"./web/Themes/default/imges/post_status_new_ln.gif";//set image url
}
else
{
TableCell cell = (TableCell)item["GridImageColumn"];
cell.Text =
" ";//clears image column
}
}
}
Exception is thrown in this line
GridDataItem
item = (GridDataItem)e.Item.DataItem;
Help me with the solution