This is a migrated thread and some comments may be shown as answers.
Batch Edit, File Upload
5 Answers 24 Views
This is a migrated thread and some comments may be shown as answers.
Mohammad
Top achievements
Rank 1
Mohammad asked on 15 Apr 2015, 08:29 AM

How can I use RadUpload or RadAsyncUpload control in RadGrid batch edit mode?

I tried following code but RadAsyncUpload shows 0 files in UploadedFile enumerator.

 

01.protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
02.    {
03.        foreach (GridBatchEditingCommand command in e.Commands)
04.        {
05.            if ((command.Type == GridBatchEditingCommandType.Update))
06.            {
07.                Hashtable newValues = command.NewValues;
08. 
09.                if (newValues != null)
10.                {
11.                    var CTRL = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_AttachmentColumn");
12.                    RadAsyncUpload asyncUpload = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_AttachmentColumn").Controls[0] as RadAsyncUpload;
13.                     
14.                }
15.            }
16.        }
17.    }

<telerik:GridAttachmentColumn UploadControlType="RadUpload" EditFormHeaderTextFormat="Upload File:" HeaderText="Attachment Column" UniqueName="AttachmentColumn">
</telerik:GridAttachmentColumn>

5 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 20 Apr 2015, 05:54 AM
Hello,

In order to extract the uploaded file contents you can modify the logic as demonstrated below.

C#:
protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
{
    foreach (GridBatchEditingCommand command in e.Commands)
    {
        if ((command.Type == GridBatchEditingCommandType.Update))
        {
            Hashtable newValues = command.NewValues;
            if (newValues != null)
            {
                byte[] file = (byte[])newValues["AttachmentColumn"];
            }
        }
    }
}
More information about accessing the user changes can be found in this help article.

Regards,
Angel Petrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Mohammad
Top achievements
Rank 1
answered on 20 Apr 2015, 07:47 AM

How I will add column for above mentioned code?

It will be without TemplateColumn of I have to use RadUpload or RadAsyncUpload control inside TemplateColumn?

0
Angel Petrov
Telerik team
answered on 23 Apr 2015, 07:09 AM
Hi,

I am experiencing difficulties understanding the query. Do you want to replace the GridAttachmentColumn with a GridTemplateColumn? If that is the case you may need to manually handle the editing process for the column. The idea here is to subscribe to the four batch editing events(OnBatchEditGetCellValue, OnBatchEditSetEditorValue, OnBatchEditGetEditorValue and OnBatchEditSetCellValue) and manually get set the cell/editor values. An example of such type of handling can be observed here.

Regards,
Angel Petrov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
bosseman
Top achievements
Rank 1
answered on 21 Nov 2016, 06:03 PM

Greetings, I can retrieve the byte array from the newValues hashtable after using the RadAsyncUpload control in a batch edit mode data grid. How can I retrieve the actual name of the file in addition to the contents? 

Thank you.

Jim

0
Angel Petrov
Telerik team
answered on 24 Nov 2016, 08:35 AM
Hello Jim,

I am sorry to say but there isn't an exposed way to obtain the file name. You can however obtain a reference to the file upload control and its UploadedFiles collection. From there you may need to access the input stream of each file and compare it with the provided data.

C#:
foreach (GridBatchEditingCommand command in e.Commands)
        {
            if ((command.Type == GridBatchEditingCommandType.Update))
            {
                Hashtable newValues = command.NewValues;
                if (newValues != null)
                {
                    byte[] file = (byte[])newValues["AttachmentColumn"];
 
                    // access the uploaded files
                    ((RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_AttachmentColumn").Controls[0] as RadAsyncUpload)).UploadedFiles
                }
            }
        }


Regards,
Angel Petrov
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Tags
Grid
Asked by
Mohammad
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Mohammad
Top achievements
Rank 1
bosseman
Top achievements
Rank 1
Share this question
or