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

How to get uploaded files by row in Radgrid mode edit batch

4 Answers 239 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Clément
Top achievements
Rank 1
Clément asked on 06 Oct 2014, 10:25 AM
Hi,

I am using the radasyncupload in a RadGrid.The MasterTavleView is set up to EditMode="Batch" and i use a GridtemplateColumn for the radasyncupload :

<telerik:GridTemplateColumn HeaderText="AttachedFile" UniqueName="UploadColumn">
<ItemTemplate>
<telerik:RadListBox runat="server" ID="listBox1">
 <ItemTemplate>
<a href="<%# DataBinder.Eval(Container.DataItem, "Url")%>">Lien <%# DataBinder.Eval(Container.DataItem,"Name")%></a>
 </ItemTemplate>
</telerik:RadListBox>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadAsyncUpload runat="server" D="AsyncUpload1" OnFileUploaded="AsyncUpload1_FileUploaded" AllowedFileExtensions="jpg,jpeg,png,gif,pdf" MaxFileSize="1048576"  MultipleFileSelection="Automatic">
</telerik:RadAsyncUpload>
</EditItemTemplate>
</telerik:GridTemplateColumn>

When the user finish to edit a row i can find the RadAsync control in  BatchEditCommand event :

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)
                {
                    RadAsyncUpload asyncUpload = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_UploadColumn").FindControl("AsyncUpload1") as RadAsyncUpload;
                    //Here i need to get files by row or DataKeyNames
                    foreach (var item in asyncUpload.UploadedFiles)
                    {
 
                    }
                }
            }
        }
    }


The radAsyncControl show me all the file uploaded so i can't get the file uploaded by row. I need to know files uploaded by row to save them in database.
Is there a way to get file uploaded by row or DataKeyNames with EdimtMode="Batch" ?




4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 09 Oct 2014, 07:54 AM
Hello Clément,

If you have all file names within the NewValues collection of the commands, what you have to do is to traverse each item in the UploadedFiles collection and determine if the file name matches a value from the NewValues:
foreach (UploadedFile item in asyncUpload.UploadedFiles)
{
    if (item.FileName == "the name from the newValues")
    {
        // save ...
    }
}

Since each column has only one editor when Batch Editing is used, all files from all rows will be in the UploadedFiles collection, so you will have to manually determine which file correspond to the specific row by matching the file names.

Hope this information will help with your requirement.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
JV
Top achievements
Rank 1
answered on 30 Dec 2014, 05:19 AM
Hello Clément,

The same scenario I want to implement in my radgrid batchedit mode, for multiple file upload. I tried but failed. Can you please share a sample project with multiple file asyncupload in each row of batchedit.
Thanks
JV
0
JV
Top achievements
Rank 1
answered on 30 Dec 2014, 05:22 AM
Hello Clément,

I am also trying to implement multiple file upload in each row of Batchedit of rad grid. Still I am having problem to implement this. Can you please share your sample project?

Thanks
JV
0
Konstantin Dikov
Telerik team
answered on 30 Dec 2014, 07:26 AM
Hello,

Multiple file upload with Batch Editing is not supported scenario and we can not provide a sample project with such implementation.

You could however go through our help article for Batch Editing and decide whether or not you could implement such custom functionality:


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
AsyncUpload
Asked by
Clément
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
JV
Top achievements
Rank 1
Share this question
or