I have a grid with autogenerate columns set to true.
In ItemDataBound I add an image to a cell.
protected
void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (this.reportProvider.HtmParams.ImageColumns.IsConfigColumn("TargetMet"))
{
if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
{
if (e.Item.DataItem != null)
{
DataRowView row = (DataRowView)e.Item.DataItem;
string sImg = ImageColumnHandler.GetImage(ImageColumnHandler.KPI_TARGET, System.Convert.ToDouble(row["TargetMet"]));
Image img = new Image();
img.ImageUrl =
this.Request.ApplicationPath + "/Images/" + sImg;
GridDataItem item = (GridDataItem)e.Item;
TableCell cell = item["TargetMet"];
cell.Controls.Clear();
cell.Controls.Add(img);
}
}
}
}
In Html it looks just wonderfull.
Pdf export fails to display the image. It just shows the value from the datasource.
How can I add images in codebehind to a RadGrid with autogenerate columns set to true in a way it is safe for pdf export?