会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
K!ngZ 随笔
K!ngZ 随笔
博客园
首页
新随笔
联系
订阅
管理
ReportViewer动态加载报表文件
/**/
/*
页面上放置一个ReportViewer1和两个按钮ButtonBing,ButtonXian点不同的按钮ReportViewer1显示不同的报表文件(Reportxian.rdlc和Reportbing.rdlc)
*/
protected
void
ButtonXian_Click(
object
sender, EventArgs e)
...
{
ControlCollection coll
=
ReportViewer1.Parent.Controls;
int
oldIndex
=
coll.IndexOf(ReportViewer1);
ReportViewer newViewer
=
new
ReportViewer();
coll.AddAt(oldIndex, newViewer);
coll.Remove(ReportViewer1);
newViewer.LocalReport.DataSources.Clear();
newViewer.LocalReport.ReportPath
=
MapPath(
"
Reportxian.rdlc
"
);
newViewer.LocalReport.ReportEmbeddedResource
=
"
Reportxian.rdlc
"
;
ReportDataSource rpt
=
new
ReportDataSource(
"
DataSet1_ShowOneFruit
"
, ds.Tables[
"
table
"
]);
newViewer.LocalReport.DataSources.Add(rpt);
newViewer.LocalReport.Refresh();
}
protected
void
ButtonBing_Click(
object
sender, EventArgs e)
...
{
ControlCollection coll
=
ReportViewer1.Parent.Controls;
int
oldIndex
=
coll.IndexOf(ReportViewer1);
ReportViewer newViewer
=
new
ReportViewer();
coll.AddAt(oldIndex, newViewer);
coll.Remove(ReportViewer1);
newViewer.LocalReport.DataSources.Clear();
newViewer.LocalReport.ReportPath
=
MapPath(
"
Reportbing.rdlc
"
);
newViewer.LocalReport.ReportEmbeddedResource
=
"
Reportbing.rdlc
"
;
ReportDataSource rpt
=
new
ReportDataSource(
"
DataSet1_ShowOneFruit
"
, ds.Tables[
"
table2
"
]);
newViewer.LocalReport.DataSources.Add(rpt);
newViewer.LocalReport.Refresh();
}
posted @
2007-10-19 16:57
K!ngZ
阅读(
2218
) 评论(
4
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告