This is a migrated thread and some comments may be shown as answers.

Place image in column using itemdatabound

1 Answer 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Donald Norris
Top achievements
Rank 1
Donald Norris asked on 19 Apr 2010, 12:04 AM
I have a library that will read a PDF file from disk and convert page 1 to a bitmap, how do I place it in an image or binaryimage column in a grid without writing it back out to disk?

Thanks

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Apr 2010, 02:52 PM
Hello Donald,

Having said "without writing it back out to disk", I believe you have the converted image in some form of binary data in memory. And you need to pass it on to a grid cell for display. If this is the case, then the most viable option for you would be to have a GridTemplateColumn with a RadBinaryImage in the ItemTemplate:

<telerik:GridTemplateColumn HeaderText="Image" UniqueName="Image">
    <ItemTemplate>
        <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

Now you can use the ItemDataBound event of the grid to find the binary image and set its source data:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        RadBinaryImage binaryImage = item["Image"].FindControl("RadBinaryImage1");
        binaryImage.DataValue = imageData; //imageData is the binary image data in byte[]
    }
}

Check it out.


Regards,
Veli
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Donald Norris
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or