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

Custom Exporting Radgrid content to pdf

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 06 Jan 2014, 02:59 PM
Hi,

I Need to export the radgrid content to pdf on button click and need to send that pdf as an attachment in mail.

 The button is placed outside the grid. i used the following code but it prompts "Do you want to open or save?".
RadGrid1.GridExporting += new OnGridExportingEventHandler(RadGrid1_GridExporting);
            RadGrid1.ExportSettings.FileName = FileName;
           
            RadGrid1.MasterTableView.ExportToPdf();

 

For my requirement i need to export the content to pdf and send as attachment.

 Can any one please help me inorder to achieve the same.

 

 

Thanks in Advance
Jai

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 09 Jan 2014, 12:19 PM
Hi Jai,

You could use the following code snippet to export RadGrid to the server and send it as an attachment to an email.
protected void RadGrid1_GridExporting(object sender, GridExportingArgs e)
{
    using (FileStream fs = new FileStream(String.Format("{0}.{1}", PhysicalPathToFile, RadComboBox1.SelectedValue), FileMode.Create))
    {
        byte[] output = Encoding.GetEncoding(WesternEuropean).GetBytes(e.ExportOutput);
        fs.Write(output, 0, output.Length);
    }
 
    Response.Redirect(Request.Url.GetLeftPart(UriPartial.Path).ToString());
}

You could examine the following sample which demonstrates how to achieve that.

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Jay
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or