C# 在Crystal Reports中设置子报表文本对象

C# 在Crystal Reports中设置子报表文本对象,c#,crystal-reports,subreport,C#,Crystal Reports,Subreport,我想通过资源文件设置子报表标题文本 ReportDocument rDocument = (ReportDocument)Session["ReportSource"]; ((TextObject)rDocument.Subreports["HolidaySubReport"].ReportDefinition. ReportObjects["HolidaySchedule"]).Text=Resources.Resources.HolidaySchedule; 但在这里,我得到了错

我想通过资源文件设置子报表标题文本

  ReportDocument rDocument = (ReportDocument)Session["ReportSource"];

 ((TextObject)rDocument.Subreports["HolidaySubReport"].ReportDefinition.
 ReportObjects["HolidaySchedule"]).Text=Resources.Resources.HolidaySchedule;
但在这里,我得到了错误,因为对象引用并没有设置为对象的实例


我如何解决这个问题。如果有任何帮助,我们将不胜感激。

您在哪一行收到此错误?第二行,当转换到文本对象时,您是否检查了rDocument.Subreports中是否存在HolidaySubReport?谢谢您完全正确。问题是我给出了对象名称而不是子报告名称。请添加一些文本来描述您的修复以及它如何解决问题。堆栈溢出时,只使用代码的答案不受欢迎。
TextObject txtpentotal = (TextObject)objRpt.Subreports["Subreport.rpt"].ReportDefinition.Sections["Section4"].ReportObjects["txttotal"];
txtpentotal.Text = pen.Text;