We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Image column from DataSource mapping

Hi, I have a problem with the GGC that I can't figure out. I have to display Users in my GGC with a column image representing the Profile Picture.
  • How can I map the Image Column to the datasource field that contains the image data?
  • Which data type should the field use? Byte array, Bitmap, Image...

The column is already set with Apperance.AnyRecordFieldCell.CellType = Image.

Thanks


1 Reply

AR Arulpriya Ramalingam Syncfusion Team September 14, 2017 06:12 AM UTC

Hi Alessandro,   
   
Thanks for using Syncfusion products.   
   
Suggestion 1   
   
We could understand your scenario. In order to populate the images from the datasource, the corresponding column type can be set as Byte[] array in DataSource. The images will be loaded into the grid by its corresponding byte values. Please make use of below code and sample,   
   
Code example:   
   
   
//To add the image column into DataTable   
dataTable.Columns.Add("Image"typeof(byte[]));   
   
//To add the image for the ImageColumn   
Byte[] imageArray = System.IO.File.ReadAllBytes(FindFile(@"flower" + i % 3 + ".jpg"));   
dataRow[3] = imageArray;   
   
//To set the datasource   
this.gridGroupingControl1.DataSource = dataTable;   
   
   
   
Suggestion 2   
   
In order to load the image for an Image CellType column, the following ways can also be used,   
  • QueryCellStyleInfo event.
  • Using Appearance property.
  
Please refer to the below KB link.   
   
Regards,   
Arulpriya   


Loader.
Live Chat Icon For mobile
Up arrow icon