If reportviewer is used in Form application, ReportPath can be set.
But in asp.net the same method does not work.
protected void Button1_Click(object sender, EventArgs e)
{
if (this.strOrderBy == "Customer")
{
this.rvPrice.LocalReport.ReportPath = @"Report\PriceCustomer.rdlc";
}
else
{
this.rvPrice.LocalReport.ReportPath = @"Report\PricePart.rdlc";
}
......
}
Report definition is still the old one.

How to let ReportViewer in ASP.net 2.0 local mode to change Report definition
RG6
For information the:
Me.ReportViewer1.Reset()
Is now in VS2005 SP1. This will allow you to change the report dynamically eg:
Dim DataTable As New DataSetReports.DataTable_MainPDFDataTable Dim DataRow As DataSetReports.DataTable_MainPDFRow = CType(DataTable.NewRow, DataSetReports.DataTable_MainPDFRow)DataRow.BodyText =
Me.uiTextBoxBody.TextDataTable.Rows.Add(DataRow)
Me.ReportViewer1.Reset() Me.ReportViewer1.LocalReport.ReportPath = "Reports/MainCommunication.rdlc" Me.ReportViewer1.LocalReport.DataSources.Clear()
Dim DataSource As Microsoft.Reporting.WebForms.ReportDataSource = _ New Microsoft.Reporting.WebForms.ReportDataSource("DataSetReports_DataTable_MainPDF", DataTable)ReportViewer1.LocalReport.DataSources.Add(DataSource)
ReportViewer1.LocalReport.Refresh()
harrha19
You are instantiating a new instance of the viewer, but it is not being associated with the webform. The old instance is still the one being rendered. Try something like this:
ControlCollection coll = oldViewer.Parent.Controls;
int oldIndex = coll.IndexOf(oldViewer);
ReportViewer newViewer = new ReportViewer();
coll.AddAt(oldIndex, newViewer);
coll.Remove(oldViewer);
koolsandy
thanks a lot for this wonderful information...
now my problem is that how can i bind image to rdlc..
thanks in advance
Turru
Thanks this was helpful. Here was my additions to replace the current ReportViewer control on the ASP.NET page. Any ideas when the Reset() command like in Winforms will be available in Webforms Thanks again.
oldViewer = this.ReportViewer1;ControlCollection coll = oldViewer.Parent.Controls;
int oldIndex = coll.IndexOf(oldViewer);
ReportViewer ReportViewer1 = new ReportViewer();
// Set Processing Mode
ReportViewer1.ProcessingMode =
ProcessingMode.Local; // Set reportviewer sizeReportViewer1.Height =
new Unit("550px");ReportViewer1.Width =
new Unit("100%");ReportViewer1.ID =
"ReportViewer1"; // Set default valuesReportViewer1.ShowExportControls =
false;ReportViewer1.ShowBackButton =
false;ReportViewer1.SizeToReportContent =
true; // Reset the control collection positioncoll.AddAt(oldIndex, ReportViewer1);
coll.Remove(oldViewer);
dmcgiv
The latest information is available here: http://msdn.microsoft.com/vstudio/support/servicing/default.aspx
GTG
Ferry Meidianto
p818632
notoryus
Thx Brian!
But do you mean to do as follow
protected void Button1_Click(object sender, EventArgs e)
{
if (this.strOrderBy == "Customer")
{this.rvPrice = new ReportViewer();
this.rvPrice.LocalReport.ReportPath = @"Report\PriceCustomer.rdlc";
}
else
{this.rvPrice = new ReportViewer();
this.rvPrice.LocalReport.ReportPath = @"Report\PricePart.rdlc";
}
......
}
It seems does not work.
sabfix
On possible solution is place both reports with separate reportviewer controls on the web page (configure datasources, GetData metod) and
then leave only reportviewer on the page (delete all other reports reportviewer controls, but leave objectdatasources on the page )
so,you must in PageLoad first remove existing ReportViewer Control
ControlCollection coll = this.ReportViewerHouseFlats.Parent.Controls;//remember the place, there the old ReportViewer was
int oldIndex = coll.IndexOf(this.ReportViewerHouseFlats);
//remove in from the page
coll.Remove(this.ReportViewerHouseFlats);
//then add new control
ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();
ReportViewer1.Height = Unit.Parse("490px");
ReportViewer1.Width = Unit.Parse("100%");
coll.AddAt(oldIndex, ReportViewer1);
this.ReportViewer1.LocalReport.DataSources.Clear()
//and set new control report and datasources
this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Raportid/HouseFlats.rdlc");this.ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("dsHouses_HOUSE_FLATS_FOR_WORKER_KUIDO_S", ObjectDataSourceHouseFlats));
this.ReportViewer1.Visible = true;