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

How to Display Images automatically in my GridImageColumn from my images folder?

1 Answer 340 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cece
Top achievements
Rank 1
Cece asked on 07 Jun 2019, 04:19 PM

     I'm trying to display images on my gridimagecolumn without me having to upload it myself but instead it does it automatically when i load the grid. How do I do that? 

 

My template is => 

 <telerik:GridBinaryImageColumn  DataField="Profile" HeaderText="Profile" UniqueName="Upload" ImageHeight="60px" ImageWidth="60px" ResizeMode="Fit"></telerik:GridBinaryImageColumn>   

 

I haven't yet figure the code out on how to go about this...This is what I have so far.

protected void uxUsedGrid_InsertCommand(object source, GridCommandEventArgs e)
        {
            _InsertCommand(source, e);
        }
 
        private void _InsertCommand(object source, GridCommandEventArgs e)
        {
 
            GridEditFormInsertItem insertItem = e.Item as GridEditFormInsertItem;
            RadAsyncUpload radAsyncUpload = insertItem["Upload"].FindControl("AsyncUpload1") as RadAsyncUpload;
 
            UploadedFile file = radAsyncUpload.UploadedFiles[0];
            byte[] fileData = new byte[file.InputStream.Length];
            file.InputStream.Read(fileData, 0, (int)file.InputStream.Length);
 
            
        }
 
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        {
            long totalBytes = 0;
            int MaxTotalBytes = 1000000;
            if ((totalBytes < MaxTotalBytes) && (e.File.ContentLength < MaxTotalBytes))
            {
                e.IsValid = true;
                totalBytes += e.File.ContentLength;
                IsRadAsyncValid = true;
            }
            else
            {
                e.IsValid = false;
                IsRadAsyncValid = false;
            }
        }

 

I have look at this Demo and while it was helpful, it mostly focused on the client uploading the files and basing it off from that to upload the images. 

Any help is appreciated!

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 12 Jun 2019, 11:50 AM
Hi Cece,

The GridImageColumn is suitable for images coming from a database field. For other scenarios, you can try using an ItemTemplate and display the image the same way you would have displayed it on a regular aspx page:
https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/columns/column-types#gridtemplatecolumn

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Cece
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or