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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I need some example of the grid loading img from database saved like byte[]

Thread ID:





143560 Mar 26,2019 07:53 PM UTC Apr 5,2019 05:57 AM UTC ASP.NET Core - EJ 2 3
Tags: DataGrid
Asked On March 26, 2019 07:53 PM UTC

I need some example of the grid loading img from database saved like byte[] (with Net core 2 Razor Pages)

Thavasianand Sankaranarayanan [Syncfusion]
Replied On March 28, 2019 03:38 AM UTC

Hi Nelson, 

Greetings from Syncfusion support. 

You need to follow the below steps to achieve this requirement. 

Step #1: First you need to convert the byte array to base64 string. You can achieve this requirement like as following code snippet, 

string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); // Convert the bytes to base64 string 

Step #2: You need to add this converted base64 string with Grid data source. 

Step #3: When you display the image in Grid to column, you need to convert this base64 string to image. We suggest you to use queryCellInfo event of the Grid to achieve this requirement. Please refer the following code snippet, 

function queryCellInfo(args) { // Grid queyCellInfo event 
        if (args.column.field == "Image") { 
           var image = new Image(); 
            image.src = "data:image/png;base64," + args.data.Image; // base64 string 
            args.cell.appendChild(image); // Appended the image to particular cell 

In this code we have converted and appended the based64 string to Grid cell with the help of Grid queryCellInfo event. You can access the base64 string in this queryCellInfo event argument(i.e args.data). 

Thavasianand S. 

Replied On April 4, 2019 08:10 PM UTC

Thanks. This help me a lot

Hariharan J V [Syncfusion]
Replied On April 5, 2019 05:57 AM UTC


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon