rdlc子报表问题 各位大侠,如何后台控制rdlc报表中子报表的数量,可不可以通过后台代码向rdlc报表中动态添加SubReport,并且为其指定子报表? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个已经解决了,不过实现起来代码还是很多的,如下方案仅供参考,如果哪位大侠还有更好的办法可以告诉我滴,谢谢各位主要是修改RDLC主报表中子报表的名称,从而实现一种动态加载子报表的功能,首先加载RDLC文件到XmlDocument中,找到SubReport节点,对其子报表名称进行修改:(部分代码如下)ModifyAnySubreport(listsubreportname, rdlcReportPath); //加载主报表 DefineMainReport(rdlcReportPath); //加载子报表 foreach (string s in listsubreportname) { string subReportPath = @"E:\学习的东西(程序)\WinForm中都有哪些可用报表\RDLC\RDLCPrint\RDLCPrint\Reports\" + s + ".rdlc"; StreamReader subReport = new StreamReader(subReportPath); this.reportViewer1.LocalReport.LoadSubreportDefinition(s, subReport); } this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessingNKWKAndYK); this.reportViewer1.RefreshReport();void ModifyAnySubreport(List<string> listsubreportname, string rdlcReprotPath){ int i = 0; XmlDocument doc = new XmlDocument(); doc.Load(rdlcReprotPath); XmlNodeList element = doc.GetElementsByTagName("Subreport"); foreach (XmlNode node in element) { XmlNode n = (XmlNode)node.ChildNodes[1]; n.InnerText = listsubreportname[i].ToString(); i++; } doc.Save(rdlcReprotPath); } CheckBoxList如何读取数据 strA = "doc" 想判断是不是{ "pdf" , "doc" , "ppt" }中的一种,怎么写最好? 业务实体和数据层有什么区别? 加载窗体到内存(新手请教) 关于SqlDataReader 读数问题 winform和web的混合程序的登陆问题 .NET 应用程序 部署问题 C#中程序员可以不用考虑内存拉圾的处理了吗? 一个很菜的问题,请不要笑 OleDbConnection中的连接字符串的菜鸟问题 怎么高效率点获取文件夹的大小值 c#中datagridview样式怎么设置?
主要是修改RDLC主报表中子报表的名称,从而实现一种动态加载子报表的功能,首先加载RDLC文件到XmlDocument中,找到SubReport节点,对其子报表名称进行修改:(部分代码如下)
ModifyAnySubreport(listsubreportname, rdlcReportPath);
//加载主报表
DefineMainReport(rdlcReportPath);
//加载子报表
foreach (string s in listsubreportname)
{
string subReportPath = @"E:\学习的东西(程序)\WinForm中都有哪些可用报表\RDLC\RDLCPrint\RDLCPrint\Reports\" + s + ".rdlc";
StreamReader subReport = new StreamReader(subReportPath);
this.reportViewer1.LocalReport.LoadSubreportDefinition(s, subReport);
} this.reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessingNKWKAndYK);
this.reportViewer1.RefreshReport();void ModifyAnySubreport(List<string> listsubreportname, string rdlcReprotPath)
{
int i = 0;
XmlDocument doc = new XmlDocument();
doc.Load(rdlcReprotPath); XmlNodeList element = doc.GetElementsByTagName("Subreport");
foreach (XmlNode node in element)
{
XmlNode n = (XmlNode)node.ChildNodes[1];
n.InnerText = listsubreportname[i].ToString();
i++;
}
doc.Save(rdlcReprotPath);
}