Access to RadAsyncUpload in GridTemplateColumn on OnBatchEditCommand event

2 posts, 0 answers
  1. Alexandr
    Alexandr avatar
    1 posts
    Member since:
    Dec 2016

    Posted 23 Aug 2017 Link to this post



    I have a grid with row BatchEditMode and GridTemplateColumn with RadAsyncUpload in Edittemplate. I try to save file to fileserver on OnBatchEditCommand, but I can not access to RadAsyncUpload from code behind.


    <telerik:RadGrid runat="server" Skin="Metro" RenderMode="Lightweight" ID="gvAuditorium" AutoGenerateColumns="False" DataSourceID="dsAuditorium"
        AllowAutomaticDeletes="false" AllowAutomaticInserts="False" AllowAutomaticUpdates="False" AllowPaging="True"
        <MasterTableView DataKeyNames="RoomId" PageSize="50" EditMode="Batch" CommandItemDisplay="TopAndBottom">
            <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False"></CommandItemSettings>
            <BatchEditingSettings EditType="Row" OpenEditingEvent="Click"></BatchEditingSettings>         
                <telerik:GridBoundColumn DataField="Number" SortExpression="Number" UniqueName="Number" HeaderText="Номер аудитории" ReadOnly="True"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="RoomName" SortExpression="RoomName" UniqueName="RoomName" HeaderText="Название" ReadOnly="True"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TypeRoomName" SortExpression="TypeRoomName" UniqueName="TypeRoomName" HeaderText="Тип аудитории" ReadOnly="True"></telerik:GridBoundColumn>
                <telerik:GridNumericColumn DataField="Square" SortExpression="Square" UniqueName="Square" DataFormatString="{0:N2}" DecimalDigits="2" HeaderText="Площадь" />
                <telerik:GridNumericColumn DataField="PlaceCount" SortExpression="PlaceCount" UniqueName="PlaceCount" DecimalDigits="0" DataFormatString="{0:0}" HeaderText="Количество мест"/>          
                <telerik:GridTemplateColumn DataField="ScanFileName" UniqueName="ScanFileName" HeaderText="План аудитории">
                        <asp:HyperLink runat="server" ID="hlToFile" Target="_blank" Visible='<%# Eval("hasFile") %>' Text='<%# Bind("ScanFileName") %>' NavigateUrl='<%# "~/_layouts/15/FastAuditoriumFilling/AuditoriumFileDownload.aspx?RoomId=" + Eval("RoomId")  %>' ></asp:HyperLink>
                        <telerik:RadAsyncUpload runat="server" ID="auFileUpload" Skin="Metro" RenderMode="Lightweight" AllowedFileExtensions="pdf" ></telerik:RadAsyncUpload>
    protected void gvAuditorium_OnBatchEditCommand(object sender, GridBatchEditingEventArgs e)
                if (e.Commands.Count > 0)
                    foreach (var editingCommand in e.Commands)
                        int roomId = (int)editingCommand.Item.GetDataKeyValue("RoomId");
                        Hashtable newValues = editingCommand.NewValues;
                        RadAsyncUpload auFileUpload = gvAuditorium.FindControl(gvAuditorium.MasterTableView.ClientID + "_ScanFileName").FindControl("auFileUpload") as RadAsyncUpload;
                        if (auFileUpload != null && auFileUpload.UploadedFiles.Count > 0)
                            //SAVE FILE
                        //SAVE DATA TO DB

    If e.Commands.Count == 1, then all OK, but if e.Commands.Count > 1 then RadAsyncUpload auFileUpload = gvAuditorium.FindControl(gvAuditorium.MasterTableView.ClientID +"_ScanFileName").FindControl("auFileUpload") as RadAsyncUpload; get always first edit control.

    How can I save files from all edited lines?

  2. Marin Bratanov
    Marin Bratanov avatar
    5929 posts

    Posted 28 Aug 2017 Link to this post

    Hello Alexandr,

    The batch edit mode works entirely on the client and serializes string data to send to the server so it will fire the BatchEditComamnd.

    The way this works is that there is a single edit row that gets moved in the DOM where necessary (where the cell is opened for editing).

    This means that there is a single RadAsyncUpload on the client-side rendering of the page.

    Thus, an async upload is not supported with batch editing because it requires server operations in order to complete a file upload.

    What I can suggest you look into is the following approaches:

    • Extract some functionality in a popup (similar to this demo). You can put the async upload there together with non-required data, for example.
    • Or, create a custom handler for the async upload and save the files in the handler itself instead of using the async upload instance.
    • Or, try using a GridAttachmentColumn as discussed in this forum thread.
    • Or, use the InPlace edit mode instead of the batch edit mode.



    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top