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

RadAsyncUpload in RadGrid

8 Answers 468 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jagat
Top achievements
Rank 1
Jagat asked on 10 Apr 2012, 11:49 PM
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

8 Answers, 1 is accepted

Sort by
0
Jagat
Top achievements
Rank 1
answered on 12 Apr 2012, 08:14 PM
Any Help...??
0
Ramkumar
Top achievements
Rank 1
answered on 29 Nov 2013, 09:54 AM
Can any one please say whether we can use RadAsyncUpload inside RadAjaxPanal??
0
Shinu
Top achievements
Rank 2
answered on 29 Nov 2013, 11:21 AM
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.
0
Ramkumar
Top achievements
Rank 1
answered on 29 Nov 2013, 12:39 PM
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.
0
Shinu
Top achievements
Rank 2
answered on 30 Nov 2013, 02:29 AM
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.
0
Ramkumar
Top achievements
Rank 1
answered on 02 Dec 2013, 06:46 AM
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.
0
Shinu
Top achievements
Rank 2
answered on 02 Dec 2013, 08:54 AM
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.
0
Ramkumar
Top achievements
Rank 1
answered on 03 Dec 2013, 05:49 AM
Hi Shinu,
   What you coded is correct the same code i Used and it is working fine at my end.
Tags
Grid
Asked by
Jagat
Top achievements
Rank 1
Answers by
Jagat
Top achievements
Rank 1
Ramkumar
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or