How can i add selected files in grid using RadAsyncUpload

4 posts, 0 answers
  1. Jagadeeswararao
    Jagadeeswararao avatar
    15 posts
    Member since:
    Sep 2013

    Posted 23 Sep 2013 Link to this post

    I have a requirement that, when  selected(RadAsyncUpload) a file, the file details should be populated in grid on the same window. how can i implement.
    File details like : size , name , path.

    Please help me
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2013 Link to this post

    Hi Jagadeeswararao,

    Please take a look into the following code snippet I tried to display the selected file name and size in the client side. Due to some Browser restrictionit is not possible to  access the path of the selected file in RadAsyncUpload.

    ASPX:
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" TargetFolder="Uploads"
        OnClientProgressUpdating="OnClientProgressUpdating">
    </telerik:RadAsyncUpload>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="false" AutoGenerateColumns="false"
        CssClass="grid">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="FileName" HeaderText="ID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="FileSize" HeaderText="Text">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnCommand="function(){}" />
        </ClientSettings>
    </telerik:RadGrid>

    JavaScript:
    <script type="text/javascript">
        var data = new Array();
        function OnClientProgressUpdating(sender, args) {
            var filename = args.get_data().fileName; // selected file name
            var filesize = args.get_data().fileSize; //selected file size
            data = [{ "FileName": filename, "FileSize": filesize}];
            $find("RadGrid1").removeCssClass("grid");
            $find("RadGrid1").addCssClass("grid1");
            var grid = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
            grid.set_dataSource(data); //adding file name and size into grid
            grid.dataBind();
        }
    </script>

    CSS:
    <style type="text/css">
        .grid
        {
            display : none !important;
        }
        .grid1
        {
            display : block !important;
        }
    </style>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jagadeeswararao
    Jagadeeswararao avatar
    15 posts
    Member since:
    Sep 2013

    Posted 25 Sep 2013 Link to this post

    Hi Shinu,
     Thanks for responding early. I tried that code which you posted but the data(size and Name) was not populated in the Grid.
      can't find what the issue exactly.

    Thanks,
    Jagadeeswararao
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Sep 2013 Link to this post

    Hi Jagadeeswararao,

    Unfortunately I couldn't replicate the issue. The above code is working fine at my end. Please provide your code so that I can help you further.

    Thanks,
    Shinu.
Back to Top