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

[Solved] Displaying BinaryImage from sql db in grid

1 Answer 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
reynald lawrence
Top achievements
Rank 1
reynald lawrence asked on 27 Jul 2009, 02:22 PM
Hi! I have a radgrid which has GridBinaryImage column and server side code to bind the data from the grid. My problem is I still can't display the image correctly in grid even if my image is byte[] type in c# and image type in sql db.

markup:

<

 

telerik:GridBinaryImageColumn DataField="PictureImg" HeaderText="Image" UniqueName="PictureImg"

 

 

ImageAlign="Middle" ImageHeight="200px" ImageWidth="200px" ResizeMode="Fit">

 

 

<HeaderStyle Width="10%" />

 


codebehind:

 

protected class PictureTemplate

 

{

 

public Guid PictureID { get; set; }

 

 

public string PictureName { get; set; }

 

 

public byte[] PictureImg { get; set; }

 

 

public string PictureDesc { get; set; }

 

}


 

protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)

 

{

 

List<PictureTemplate> picTemplate;

 

 

using (DianaOnlinePhotoEntities db = new DianaOnlinePhotoEntities())

 

{

picTemplate = (

from p in db.tblPicture

 

 

where p.PictureID != null

 

 

select new PictureTemplate

 

{

PictureID = p.PictureID,

PictureName = p.PictureName,

PictureImg = p.PictureImg,

PictureDesc = p.PictureDesc

}).ToList();

RadGrid1.DataSource = picTemplate;

}

}


Thanks!!

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 29 Jul 2009, 11:38 AM
Hello Reynald,

It will be good if you can send us (via support ticket) small example project where we can reproduce and debug the problem.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
reynald lawrence
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or