"Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net" answered properly. Developers are finding an appropriate answer about Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net. Enter your desired code related query in the search bar and get every piece of information about C# code related question on Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net.
Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
Customers dsCustomers = GetData("SELECT TOP 10 * FROM Customers");
ReportDataSource datasource = new ReportDataSource("Customers", dsCustomers.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
}
}
private Customers GetData(string query)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlCommand cmd = new SqlCommand(query);
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (Customers dsCustomers = new Customers())
{
sda.Fill(dsCustomers, "DataTable1");
return dsCustomers;
}
}
}
}
protected void Open(object sender, EventArgs e)
{
Warning[] warnings;
string[] streamIds;
string contentType;
string encoding;
string extension;
//Export the RDLC Report to Byte Array.
byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out contentType, out encoding, out extension, out streamIds, out warnings);
// Open generated PDF.
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
}
Source: www.aspforums.net
All those coders who are working on the C# based application and are stuck on Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net can get a collection of related answers to their query. Programmers need to enter their query on Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net". Visit this developer's friendly online web community, CodeProZone, and get your queries like Export PDF from RDLC Report and open in Browser on Button Click using C# and VB.Net in ASP.Net resolved professionally and stay updated to the latest C# updates.