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

Using form template to include the upload from GridAttachmentColumn

1 Answer 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Liane French
Top achievements
Rank 1
Liane French asked on 24 Apr 2010, 04:06 AM
Dear team,

I want to use the form template in radgrid edit mode to include the upload from the GridAttachmentColumn. I am using the form template becaue it gives me more flexibility.  Howver, i tried to use the radupload control but  i did not know how to access the binary data inorder to assign it to a byte field. Can you tell me how to format and place the upload field that is imbedded in the 

GridAttachmentColumn.

Thans in advance
Troy Horsford
troyhorsford@yahoo.com

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 29 Apr 2010, 07:40 AM
Hi Liane,

If you are using a form  template, this means that you have a RadUpload control you have placed in on your own. You are not using GridAttachmentColumn's editor upload. When updating / inserting records, you need to find the custom RadUpload control by ID. You can do it in the UpdateCommand / InsertCommand event handlers, respectively. Just use e.Item.FindControl() with the ID of the RadUpload control you have placed. Once you reference the upload, you can access the binary contents using:

RadUpload radUpload = (RadUpload)e.Item.FindControl("RadUploadControlID");
if (radUpload.UploadedFiles.Count > 0)
{
    UploadedFile file = radUpload.UploadedFiles[0];
    using (Stream stream = file.InputStream)
    {
        byte[] bytes = new byte[stream.Length];
        stream.Read(bytes, 0, (int)stream.Length);
        //bytes is the binary content of your upload
    }
}


Best wishes,
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
Liane French
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or