reportviewer 这个怎么加载dll中的rdlc
展开全部
Solution 1:
使用多个ReportViewer,每个ReportViewer显示不同的RDLC。根据用户的选择显示洞卜一个ReportViewer,隐藏其他的ReportViewer。就在页面中添加多个ReportViewer控件来对应多个rdlc文件,然后根据需要显示和隐藏部分ReportViewer控件。
Solution 2:
Because there is no ReportViewer.Reset() in C#, the solution is to create an new instance of the report. The trick is to Swap out the previous ReportViewer with the New ReportViewer.
ControlCollection cc = this.ReportViewer1.Parent.Controls;
/纳核穗/get index of previous ReportViewer so we can swap it out.
int prevIndex = cc.IndexOf(this.ReportViewer1);
// Remove previous ReportViewer
cc.Remove(this.ReportViewer1);
//add new instance of ReportViewer.
ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();
// Reset report properties.
ReportViewer1.Height = Unit.Parse("100%");
ReportViewer1.Width = Unit.Parse("100%");
ReportViewer1.CssClass = "table";
//Add the new ReportViewer to the previous ReportViewer location.
cc.AddAt(prevIndex, ReportViewer1);
// Clear out any previous datasources.
this.ReportViewer1.LocalReport.DataSources.Clear();
/氏指/Set report mode for local processing.
ReportViewer1.ProcessingMode = ProcessingMode.Local;
// Create a new report dataset.
DataSet dataSet = new DataSet();
this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("ReportPeopleMailingList.rdlc");
// Load dataset.
try
{ // retrieve dataset.
dataSet = (DataSet)Session["sessionDataSetCli"]; }
catch
{
return;
}
// Assign report parameters.
Microsoft.Reporting.WebForms.ReportParameter[] parms = new Microsoft.Reporting.WebForms.ReportParameter[1];
parms[0] = new Microsoft.Reporting.WebForms.ReportParameter("title", "Clients");
ReportViewer1.LocalReport.SetParameters(parms);
// Load the dataSource.
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetPeople_adPeople", dataSet.Tables[0]));
// Refresh the ReportViewer
ReportViewer1.LocalReport.Refresh();
Dim cc As ControlCollection = ReportViewer1.Parent.Controls
Dim prevIndex As Integer = cc.IndexOf(ReportViewer1)
cc.Remove(ReportViewer1)
ReportViewer1 = New Microsoft.Reporting.WebForms.ReportViewer()
ReportViewer1.Height = Unit.Parse("450px")
ReportViewer1.Width = Unit.Parse("980px")
cc.AddAt(prevIndex, ReportViewer1)
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.ReportPath = reportPath
ReportViewer1.LocalReport.DataSources.Add(datasource)
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {.....})
ReportViewer1.LocalReport.Refresh()
Solution 3:
Must do a
ReportViewer1.Reset()
ReportViewer1.LocalReport.Dispose()
first. Then set your reportpaths, then do a
ReportViewer1.LocalReport.Refresh()
You must have VS2005 SP1 for this.
使用多个ReportViewer,每个ReportViewer显示不同的RDLC。根据用户的选择显示洞卜一个ReportViewer,隐藏其他的ReportViewer。就在页面中添加多个ReportViewer控件来对应多个rdlc文件,然后根据需要显示和隐藏部分ReportViewer控件。
Solution 2:
Because there is no ReportViewer.Reset() in C#, the solution is to create an new instance of the report. The trick is to Swap out the previous ReportViewer with the New ReportViewer.
ControlCollection cc = this.ReportViewer1.Parent.Controls;
/纳核穗/get index of previous ReportViewer so we can swap it out.
int prevIndex = cc.IndexOf(this.ReportViewer1);
// Remove previous ReportViewer
cc.Remove(this.ReportViewer1);
//add new instance of ReportViewer.
ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer();
// Reset report properties.
ReportViewer1.Height = Unit.Parse("100%");
ReportViewer1.Width = Unit.Parse("100%");
ReportViewer1.CssClass = "table";
//Add the new ReportViewer to the previous ReportViewer location.
cc.AddAt(prevIndex, ReportViewer1);
// Clear out any previous datasources.
this.ReportViewer1.LocalReport.DataSources.Clear();
/氏指/Set report mode for local processing.
ReportViewer1.ProcessingMode = ProcessingMode.Local;
// Create a new report dataset.
DataSet dataSet = new DataSet();
this.ReportViewer1.LocalReport.ReportPath = Server.MapPath("ReportPeopleMailingList.rdlc");
// Load dataset.
try
{ // retrieve dataset.
dataSet = (DataSet)Session["sessionDataSetCli"]; }
catch
{
return;
}
// Assign report parameters.
Microsoft.Reporting.WebForms.ReportParameter[] parms = new Microsoft.Reporting.WebForms.ReportParameter[1];
parms[0] = new Microsoft.Reporting.WebForms.ReportParameter("title", "Clients");
ReportViewer1.LocalReport.SetParameters(parms);
// Load the dataSource.
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetPeople_adPeople", dataSet.Tables[0]));
// Refresh the ReportViewer
ReportViewer1.LocalReport.Refresh();
Dim cc As ControlCollection = ReportViewer1.Parent.Controls
Dim prevIndex As Integer = cc.IndexOf(ReportViewer1)
cc.Remove(ReportViewer1)
ReportViewer1 = New Microsoft.Reporting.WebForms.ReportViewer()
ReportViewer1.Height = Unit.Parse("450px")
ReportViewer1.Width = Unit.Parse("980px")
cc.AddAt(prevIndex, ReportViewer1)
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.ReportPath = reportPath
ReportViewer1.LocalReport.DataSources.Add(datasource)
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {.....})
ReportViewer1.LocalReport.Refresh()
Solution 3:
Must do a
ReportViewer1.Reset()
ReportViewer1.LocalReport.Dispose()
first. Then set your reportpaths, then do a
ReportViewer1.LocalReport.Refresh()
You must have VS2005 SP1 for this.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询