RadAsyncUpload in RadGrid

10 posts, 0 answers
  1. Jagat
    Jagat avatar
    151 posts
    Member since:
    Jan 2011

    Posted 10 Apr 2012 Link to this post

    Hello,

      I have a radgrid in one of the web pages and in the template column i am using RadAsyncUpload to upload the documents(including PDF). Saving the documents in the database is fine. My problem is with viewing the documents, after they are saved.  I saw in some threads that opening these pdf docs in seperate radwindow is a way to achieve this. How do i do that?  

    1) Using the ExportPDF is the right way to do this?
    2) RadBinaryImage still not supporting PDF  format?
    3) How do i send the binary data of the document to the RadWindow?
    4) If i have multiple rows in the grid, then, do i have to select the row first and then click on export pdf?
    5) If the file size is 1 MB. Obviously, i don't want to save the document without compressing or resizing it. How do i do that without decreasing the resolution, Since the document will be pulled up for reporting purpose in the future?
    6) When i click the export button now, a new window is opening with grid information in it. It is not showing the document.

    Where am i doing wrong? 


    string url, path = "";
           bool isExport = false;
     
           protected void Page_Load(object sender, EventArgs e)
           {
               url = String.Format("~/{0}.pdf", RadGrid1.ExportSettings.FileName);
               path = Server.MapPath(url);
               
           }
     
     
    protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
           {
               if (File.Exists(path))
               {
                   File.Delete(path);
               }
     
               using (FileStream fs = File.Create(path))
               {
                   Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
                   fs.Write(info, 0, info.Length);
               }
     
               Response.Redirect("~/frm_UploadDocs.aspx");
           }
     
           protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
           {
               if (e.Item.Value == "Export")
               {
                  //RadGrid1.ExportSettings.ExportOnlyData = false;
                   isExport = true;
                   RadGrid1.MasterTableView.ExportToPdf();
               }
               else if (e.Item.Value == "Delete")
               {
                   if (File.Exists(path))
                   {
                       File.Delete(path);
                   }
               }
           }

     I followed the demo link below.
    http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandradasyncupload/defaultcs.aspx?product=grid

    http://blogs.telerik.com/vladimirenchev/posts/08-12-08/how-to-export-grid-to-pdf-file-and-show-the-result-using-the-window.aspx 



    Appreciate the help
    Thanks
  2. Jagat
    Jagat avatar
    151 posts
    Member since:
    Jan 2011

    Posted 12 Apr 2012 Link to this post

    Any Help...??
  3. Ramkumar
    Ramkumar avatar
    12 posts
    Member since:
    Nov 2013

    Posted 29 Nov 2013 Link to this post

    Can any one please say whether we can use RadAsyncUpload inside RadAjaxPanal??
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2013 Link to this post

    Hi Ramkumar,

    It is possible to use a RadAsyncUpload inside RadAjaxPanel. Please have a look into the sample code snippet which works as expected.

    ASPX:
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" OnFileUploaded="RadAsyncUpload1_FileUploaded">
        </telerik:RadAsyncUpload>
    </telerik:RadAjaxPanel>
    <telerik:RadButton ID="RadButton1" runat="server" Text="Upload">
    </telerik:RadButton>

    C#:
    protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        //This event will fire when the RadButton1 Click is happens
        //Uploaded filename
        string filename = e.File.FileName;
    }

    Thanks,
    Shinu.
  5. Ramkumar
    Ramkumar avatar
    12 posts
    Member since:
    Nov 2013

    Posted 29 Nov 2013 Link to this post

    hi Shinu.
     Thank you. but I am using the RadAysncupload in Radgrid and the radgrid is place inside the RadAjaxPanal.
    When I get to insert the data. I can't find the select Button for the RadAsyncUpload control.
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2013 Link to this post

    Hi Ramkumar,

    Please have a look into the following code snippet which works fine at my end.

    ASPX:
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
            OnInsertCommand="RadGrid1_InsertCommand" OnItemInserted="RadGrid1_ItemInserted">
            <MasterTableView CommandItemDisplay="Top">
                <Columns>
                    <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID" HeaderText="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID" HeaderText="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipAddress" UniqueName="ShipAddress" HeaderText="ShipAddress">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn>
                        <EditItemTemplate>
                            <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server">
                            </telerik:RadAsyncUpload>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings Selecting-AllowRowSelect="true">
            </ClientSettings>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>

    Thanks,
    Shinu.
  7. Ramkumar
    Ramkumar avatar
    12 posts
    Member since:
    Nov 2013

    Posted 02 Dec 2013 Link to this post

    Hi Shinu,
      Here everything works well. But once I click the insert button, I find the RadAsyncUpload control with select button invisible.
    also I tried with adding the handlers and everything. This is the problem I get. moreover the controls are in the ASCX page.
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Dec 2013 Link to this post

    Hi Ramkumar,

    Unfortunately I couldn't replicate the issue at my end. Please have a look into the full code which works fine at my end.

    ASPX:
    <uc1:GridAsyncUpload ID="GridAsyncUpload1" runat="server" />

    ASCX:
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="RadGrid1_ItemCommand">
            <MasterTableView CommandItemDisplay="Top">
                <Columns>
                    <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID" HeaderText="OrderID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID" HeaderText="CustomerID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ShipAddress" UniqueName="ShipAddress" HeaderText="ShipAddress">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn>
                        <EditItemTemplate>
                            <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server">
                            </telerik:RadAsyncUpload>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings Selecting-AllowRowSelect="true">
            </ClientSettings>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>

    ASCX C#:
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.PerformInsertCommandName)
        {
            e.Canceled = true;
        }
    }

    Please provide your full code if it doesn't help.
    Thanks,
    Shinu.
  9. Ramkumar
    Ramkumar avatar
    12 posts
    Member since:
    Nov 2013

    Posted 02 Dec 2013 Link to this post

    Hi Shinu,
       What you coded is correct the same code i Used and it is working fine at my end.
  10. Fawad
    Fawad avatar
    20 posts
    Member since:
    Nov 2014

    Posted 16 Nov 2014 in reply to Shinu Link to this post

    Hi Shinu,
    How can i grab the column names from radgrid in this event such as recordid and name columns.

    protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
    {
        //This event will fire when the RadButton1 Click is happens
        //Uploaded filename
        string filename = e.File.FileName;
    }
Back to Top