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

Adding a "View PDF" button column in RadGrid

1 Answer 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arsalan Ansari
Top achievements
Rank 1
Arsalan Ansari asked on 16 Jun 2011, 03:03 AM
Hello All,

I would like to add a "View PDF" button column in RadGrid that would allow me to collect the data in the row and show a PDF of a designed report.  Is this possible? If yes, how can i do this?

this would mean that i do not show the report viewer on the page and most of it is handled programmatically.

Thanks,

Arsalan Ansari

1 Answer, 1 is accepted

Sort by
0
Arsalan Ansari
Top achievements
Rank 1
answered on 16 Jun 2011, 05:38 AM

ok, so i figured it out but how can i open the file after saving it?

protected void rgDriversPayroll_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "ViewPDF")
        {
            GridDataItem dataBoundItem = e.Item as GridDataItem;
            DriverReportLS reportToExport = new DriverReportLS();
            ReportProcessor reportProcessor = new ReportProcessor();
            reportToExport.ReportParameters["DriverID"].Value = rcbDrivers.SelectedValue.ToString();
            reportToExport.ReportParameters["PayDay"].Value = dataBoundItem["PayDay"].Text;
 
            RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);
 
            FileStream fs = new FileStream(@"c:\test.pdf", FileMode.Append);
            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            fs.Flush();
            fs.Close();
        }
    }
Tags
General Discussions
Asked by
Arsalan Ansari
Top achievements
Rank 1
Answers by
Arsalan Ansari
Top achievements
Rank 1
Share this question
or