how to display multiple pdf page in single button click using rdlc report

Posted by Venky.Net under ASP.NET on 11/22/2012 | Points: 10 | Views : 4322 | Status : [Member] | Replies : 1
hi
i am using multi select dropdown i am selecting ex.(venky,ram)the field save in database
i want create report for seperate name ex.venky name
i am using split method split the name and store in array and give the for each condtion first time loop execute display the venky next time display ram
i am using the following code
DataTable dt = Controller.GetNameDetailsToDataset("PurchaseEnquiryReport", txtpeno.Text).Tables[0];
string[] s = (dt.Rows[0][17].ToString()).Split(',');


if (dt.Rows.Count == 0)
{
foreach (string str in s)
{
DataSet dt1 = Controller.GetNameDetailsToDataset("GetaddressforPurchaseEnquiry", str);

string issalaried = "";
DataTable DsRep = dt;
issalaried = "Y";
ReportDataSource datasource = new ReportDataSource("DataSet1", DsRep);
ReportParameter[] Param = new ReportParameter[1];
Param[0] = new ReportParameter("Param_IsSalaried", issalaried);
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = Server.MapPath("~\\Presentation Layer\\Report\\PurchaseEnquiry.rdlc");
//Datasource
viewer.LocalReport.DataSources.Add(datasource);
//viewer.LocalReport.SetParameters(Param);
viewer.LocalReport.EnableExternalImages = true;
byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
// viewer.ReportRefresh();

// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + "Purchaseenquiry" + "." + extension);
Response.Flush();
Response.BinaryWrite(bytes); // create the file
Response.End();

}
i want output first time loop excute display one pdf next time excute another pdf.




Responses

Posted by: aswinialuri-19361 on: 11/22/2012 [Member] Starter | Points: 25

Up
0
Down
hi
try this.


private void CreatePDF(string fileName)
{
// Setup DataSet
MyDataSetTableAdapters.YourTableAdapterHere ds = new MyDataSetTableAdapters.YourTableAdapterHere();


// Create Report DataSource
ReportDataSource rds = new ReportDataSource("MyDataSourceName", ds.GetData());


// Variables
Warning[] warnings;
string[] streamIds;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;


// Setup the report viewer object and get the array of bytes
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = "YourReportHere.rdlc";
viewer.LocalReport.DataSources.Add(rds); // Add datasource here


byte[] bytes = viewer.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


// Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
Response.Buffer = true;
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
Response.BinaryWrite(bytes); // create the file
Response.Flush(); // send it to the client to download

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response