Hi guys,
I'm having problems when trying to load different .rdlc files dynamically into a single ReportViewer control.
Here's the code:
Code:
private void LoadUserControl(string type)
{
Label lblTitle = (Label)Parent.FindControl("lblTitle");
ReportViewer1.LocalReport.DataSources.Clear();
Microsoft.Reporting.WebForms.ReportDataSource rpt = new Microsoft.Reporting.WebForms.ReportDataSource();
rpt.Name = "MyDataSource";
switch (Request["mode"].ToLower())
{
case "view":
switch (type.ToLower())
{
case "view1":
ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/View1.rdlc");
lblTitle.Text = "VIEW 1";
// ods: ObjectDataSource
rpt.DataSourceId = odsView1.ID;
rpt.Value = odsView1;
break;
case "view2":
ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/View2.rdlc");
lblTitle.Text = "VIEW2";
// ods: ObjectDataSource
rpt.DataSourceId = odsView2.ID;
rpt.Value = odsView2;
break;
}
break;
}
ReportViewer1.LocalReport.DataSources.Add(rpt);
ReportViewer1.LocalReport.Refresh();
}
A full screen of the code is available at
http://img262.imageshack.us/my.php?image=codebe3.png
The error message I keep getting is "A data source instance has not been supplied for the data source 'Reports_NepokretnostiIzvestajPoOsnovuOduzimanja'. "
Thanks in advance
Aleksandar Dragosavac
Belgrade, Serbia