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

5 posts, 0 answers
  1. Clément
    Clément avatar
    1 posts
    Member since:
    Jun 2014

    Posted 06 Oct 2014 Link to this post

    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" ?




  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 09 Oct 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. JV
    JV avatar
    10 posts
    Member since:
    Dec 2014

    Posted 29 Dec 2014 in reply to Clément Link to this post

    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
  5. JV
    JV avatar
    10 posts
    Member since:
    Dec 2014

    Posted 29 Dec 2014 in reply to Clément Link to this post

    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
  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 30 Dec 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017