Showing posts with label ReportViewer. Show all posts
Showing posts with label ReportViewer. Show all posts

Wednesday, June 13, 2007

ASP.NET 2.0 ReportViewer :: Continued...

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

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:
After you get everything set up and are running the tutorials, you may get this error message:

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