我如何编程设置为ASP.NET ReportViewer控件的数据源? [英] How do I programmatically set data source for ASP.NET ReportViewer control?
问题描述
我如何编程设置为ASP.NET ReportViewer控件的数据源?
How do I programmatically set the data source for the ASP.NET ReportViewer control?
我有一个VS 2008 ReportViewer控件,想了几种不同的报告之间切换。
I have a VS 2008 ReportViewer control and want to switch between a couple of different reports.
我可以通过设置报表源并刷新控制开关的报道,但我看不到的地方设置数据源。
I can switch reports by setting the report source and refreshing the control, but I can't see where to set the data source.
每个报告都有其自己的数据源,如果我配置它们最初在控制建它是好的,但我需要在它们之间进行切换。
Each report has its own data source, and if I configure them initially when the control is built it is fine, but I need to switch between them.
推荐答案
我认为问题是关于ReportViewer控件。
I assume the question is about ReportViewer control.
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsname", source));
DSNAME
是数据源的名称,你可以找到它.rdlc文件。 源
是您要在报告中显示的数据变量。
"dsname"
is the name of the data source, you can find it .rdlc file. source
is the variable with data you want to show in the report.
这篇关于我如何编程设置为ASP.NET ReportViewer控件的数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!