Only one record with subreports

edited 5:06AM in FastReport .NET
I've been playing more trying to get a report with 2 side by side subreports working.

After making some changes, deleting the datasources from inside the report itself, and using the registerdata function, I'm only seeing one record in the report when I run it.

This is the code in the report StartReport event;


private DataTable dt1;
private DataTable dt2;

protected void WebReport1_StartReport(object sender, EventArgs e)
{
TDBInterface dbInt = new TDBInterface();
dbInt.Connection = ConfigurationManager.AppSettings["ConnectionString"];

dt1 = dbInt.OpenCustomTable("Select * from DataSet");
dt2 = dbInt.OpenCustomTable("Select * from DataSet");

wrReport.Report.RegisterData(dt1, "DSMain");
wrReport.Report.RegisterData(dt2, "DSSub");
}



This is the report definition;

<?xml version="1.0" encoding="utf-8"?>
<Report ScriptLanguage="CSharp" ReportInfo.Created="06/01/2011 14:12:54" ReportInfo.Modified="06/03/2011 16:11:50" ReportInfo.CreatorVersion="1.6.41.0">
<scriptText>using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;

namespace FastReport
{
public class ReportScript
{
private void SubRegular_BeforePrint(object sender, EventArgs e)
{
string value = (string)Report.GetColumnValue("DSSub.Type");
SubRegular.Visible = ((value[0] == 'H') || (value[0] == 'R') || (value[0] == 'O'));
}

private void SubOtherTypes_BeforePrint(object sender, EventArgs e)
{
string value = (string)Report.GetColumnValue("DSSub.Type");
SubOtherTypes.Visible = !((value[0] == 'H') || (value[0] == 'R') || (value[0] == 'O'));
}
}
}
</ScriptText>
<Dictionary>
<Parameter Name="StartDate" DataType="System.String"/>
<Parameter Name="EndDate" DataType="System.String"/>
</Dictionary>
<ReportPage Name="Page1">
<ReportTitleBand Name="ReportTitle1" Width="718.2" Height="28.35">
<ShapeObject Name="Shape1" Width="718.2" Height="28.35" Fill="Glass" Fill.Color="Gainsboro" Fill.Blend="0.24" Fill.Hatch="true"/>
<TextObject Name="Text3" Left="4" Top="4" Width="207.9" Height="18.9" Text="Pay Report" VertAlign="Center" Font="Arial, 14pt"/>
</ReportTitleBand>
<PageHeaderBand Name="PageHeader1" Top="32.35" Width="718.2"/>
<DataBand Name="Data1" Top="36.35" Width="718.2" Height="78.05" Fill="Glass" Fill.Color="White" Fill.Blend="0.2" Fill.Hatch="true">
<SubreportObject Name="Subreport1" Top="58.15" Width="349.65" Height="18.9" ReportPage="Page2"/>
<SubreportObject Name="Subreport2" Left="359.1" Top="58.15" Width="349.65" Height="18.9" ReportPage="Page3"/>
<LineObject Name="Line1" Top="56.7" Width="349.65"/>
<LineObject Name="Line2" Left="359.1" Top="56.7" Width="349.65"/>
<TextObject Name="Text2" Top="37.8" Width="47.25" Height="18.9" Text="Code"/>
<TextObject Name="Text4" Left="47.25" Top="37.8" Width="75.6" Height="18.9" Text="Position"/>
<TextObject Name="Text12" Left="122.85" Top="37.8" Width="151.2" Height="18.9" Text="Date"/>
<TextObject Name="Text13" Left="274.05" Top="37.8" Width="75.6" Height="18.9" Text="Hours" HorzAlign="Right"/>
<TextObject Name="Text24" Left="359.1" Top="37.8" Width="47.25" Height="18.9" Text="Code"/>
<TextObject Name="Text25" Left="406.35" Top="37.8" Width="75.6" Height="18.9" Text="Position"/>
<TextObject Name="Text26" Left="481.95" Top="37.8" Width="151.2" Height="18.9" Text="Date"/>
<TextObject Name="Text27" Left="633.15" Top="37.8" Width="75.6" Height="18.9" Text="Hours" HorzAlign="Right"/>
<TextObject Name="Text5" Top="18.9" Width="359.1" Height="18.9" Text="Worked Hours"/>
<TextObject Name="Text15" Left="359.1" Top="18.9" Width="349.65" Height="18.9" Text="Other Hours / Allowances"/>
<TextObject Name="Text1" Width="94.5" Height="18.9" Text="Name: [DSMain.EmployeeNo]"/>
<ChildBand Name="Child1" Top="118.4" Width="718.2" Height="9.45">
<LineObject Name="Line4" Left="359.1" Width="349.65"/>
<LineObject Name="Line3" Width="349.65"/>
</ChildBand>
</DataBand>
<PageFooterBand Name="PageFooter1" Top="131.85" Width="718.2" Height="18.9">
<TextObject Name="Text7" Width="236.25" Height="18.9" Text="Printed [Date] " VertAlign="Center"/>
<TextObject Name="Text14" Left="463.05" Width="255.15" Height="18.9" Text="Page [PageN] of [TotalPages#]" HorzAlign="Right" VertAlign="Center"/>
</PageFooterBand>
</ReportPage>
<ReportPage Name="Page2">
<DataBand Name="SubRegular" Width="718.2" Height="18.9" BeforePrintEvent="SubRegular_BeforePrint">
<TextObject Name="Text9" Width="47.25" Height="18.9" Text="[DSSub.Code]"/>
<TextObject Name="Text10" Left="122.85" Width="151.2" Height="18.9" Text="[FormatDateTime([DSSub.StartTime],"Short Date")] - [FormatDateTime([DSSub.EndTime],"Short Date")]"/>
<TextObject Name="Text6" Left="66.15" Width="56.7" Height="18.9" Text="[DSSub.Position]"/>
<TextObject Name="Text11" Left="274.05" Width="75.6" Height="18.9" Text="[DSSub.Qty]" Format="Number" Format.UseLocale="true" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
<TextObject Name="Text8" Left="47.25" Width="18.9" Height="18.9" Text="[DSSub.Type]"/>
</DataBand>
</ReportPage>
<ReportPage Name="Page3">
<DataBand Name="SubOtherTypes" Width="718.2" Height="18.9" BeforePrintEvent="SubOtherTypes_BeforePrint">
<TextObject Name="Text28" Width="47.25" Height="18.9" Text="[DSSub.Code]"/>
<TextObject Name="Text29" Left="122.85" Width="151.2" Height="18.9" Text="[FormatDateTime([DSSub.StartTime],"Short Date")] - [FormatDateTime([DSSub.EndTime],"Short Date")]"/>
<TextObject Name="Text30" Left="66.15" Width="56.7" Height="18.9" Text="[DSSub.Position]"/>
<TextObject Name="Text31" Left="274.05" Width="75.6" Height="18.9" Text="[DSSub.Qty]" Format="Number" Format.UseLocale="true" HorzAlign="Right" WordWrap="false" Trimming="EllipsisCharacter"/>
<TextObject Name="Text32" Left="47.25" Width="18.9" Height="18.9" Text="[DSSub.Type]"/>
</DataBand>
</ReportPage>
</Report>

Anyone have any idea why I'm only seeing one record?

Previously I'd tried using 2 pre defined data sources, and created a relation linking DSMain.IDNo to DSSub.IDNo, with the main data band DataSource being DSMain and the DataSource of the two subreports being set to DSSub. The problem with that was I was getting 3 sets of the data.


Thanks n regrds,
L.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.