I have one report viewer wired to two different local reports and users can select the report from a dropdownlist. Here's the code to show the correct report:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
// remove previous report viewer if it exists
if (Panel1.Controls.Count > 0)
{
Panel1.Controls.Clear();
}
// create new instance of reportviewer to get around lame bug
ReportViewer rv = new ReportViewer();
ReportDataSource rds = new ReportDataSource("dsCustodians_Custodian", this.objDSRptCustodians);
rv.LocalReport.DataSources.Add(rds);
rv.Width = new Unit("100%");
rv.Height = new Unit("400px");
// set the reportpath dynamically
if (this.DropDownList1.SelectedValue == "Custodians")
{
rv.LocalReport.ReportPath = Server.MapPath("rpt_GroupedByCustodians.rdlc");
}
else if (this.DropDownList1.SelectedValue == "Departments")
{
rv.LocalReport.ReportPath = Server.MapPath("rpt_GroupedByDepartment.rdlc");
}
// add the dynamically called report to the panel
Panel1.Controls.Add(rv);
}
-Eurlist.thesol.com
I may sometimes, possibly, in intervals, sporadically, periodically, and intermittently post things I might, conceivably, likely, peradventurely, and probably feel are of interest. These topics will range from technology, business, entrepreneurship, politics, but is not limited to any of these aforementioned things. heh.
Showing posts with label ReportViewer. Show all posts
Showing posts with label ReportViewer. Show all posts
Wednesday, June 13, 2007
Tuesday, June 12, 2007
ASP.NET 2.0 ReportViewer :: Failed to enable constraints
I'm using the ASP.NET 2.0 ReportViewer in local mode for the first time (and it ROX). Here are two excellent tutorials:
An error has occurred during report processing.
Exception has been thrown by the target of an invocation.
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
You can go here for the solution to this.
One last piece of code that will save you from a migraine :)
this.ReportViewer1.LocalReport.Refresh();
Good Luck!
-Eurlist.thesol.com
- ASP.NET 2.0 ReportViewer in Local Mode - this one is great for getting setup. You need to run reportviewer.exe file on your web server. You can get the reportviewer.exe here.
- Drill Down Reports with ReportViewer ASP.NET 2.0 - this one is also excellent for demonstrating a 3 level drill down report.
An error has occurred during report processing.
Exception has been thrown by the target of an invocation.
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
You can go here for the solution to this.
One last piece of code that will save you from a migraine :)
this.ReportViewer1.LocalReport.Refresh();
Good Luck!
-Eurlist.thesol.com
Subscribe to:
Posts (Atom)