relation between master detail report by c#
hi
my code is:
DataSet dataset = new DataSet();
DataTable dt1 = new DataTable("dt1");
DataTable dt2 = new DataTable("dt2");
dt1.Columns.Add("ID");
dt1.Columns.Add("Row");
dt2.Columns.Add("ID");
dt2.Columns.Add("Row");
dt1.Rows.Add("1", "parent1");
dt1.Rows.Add("2", "parent2");
dt2.Rows.Add("1", "detail11");
dt2.Rows.Add("1", "detail12");
dt2.Rows.Add("2", "detail21");
dt2.Rows.Add("2", "detail22");
dataset.Tables.Add(dt1);
dataset.Tables.Add(dt2);
System.Data.DataColumn parentColumn = dataset.Tables[0].Columns["ID"];
System.Data.DataColumn childColumn = dataset.Tables[1].Columns["ID"];
DataRelation dataRel = new DataRelation("parent2Child", parentColumn, childColumn);
dataset.Tables[1].ParentRelations.Add(dataRel);
/////////////////////////////////////////
Report report = new Report();
report.Load("PmPlanReportIdentityF.frx");
report.RegisterData(dataset, "ds");
report.RegisterData(dataset.Tables["dt1"], "a");
report.RegisterData(dataset.Tables["dt2"], "b");
report.GetDataSource("a").Enabled = true;
ReportPage page1 = new ReportPage();
page1.Name = "Page1";
report.Pages.Add(page1);
page1.ReportTitle = new ReportTitleBand();
page1.ReportTitle.Name = "ReportTitle1";
page1.ReportTitle.Height = Units.Millimeters * 15f;
TextObject SchoolTitleText = new TextObject();
SchoolTitleText.Name = "SchoolTitle";
SchoolTitleText.Bounds = new RectangleF(0, 0,
Units.Centimeters * 19, Units.Centimeters * 1);
SchoolTitleText.Text = "NorthDale School";
SchoolTitleText.HorzAlign = HorzAlign.Left;
SchoolTitleText.Font = new Font("Tahoma", 14, FontStyle.Bold);
page1.ReportTitle.Objects.Add(SchoolTitleText);
GroupHeaderBand group1 = new GroupHeaderBand();
group1.Name = "GroupHeader1";
group1.Height = Units.Centimeters * 1;
group1.Condition = "[a.ID]";
page1.Bands.Add(group1);
group1.GroupFooter = new GroupFooterBand();
group1.GroupFooter.Name = "GroupFooter1";
group1.GroupFooter.Height = Units.Millimeters * 5;
DataBand databand1 = new DataBand();
databand1.Name = "Data1";
databand1.Height = Units.Centimeters * 0.5f;
databand1.DataSource = report.GetDataSource("a");
group1.Data = databand1;
TextObject TeacherText = new TextObject();
TeacherText.Name = "TeacherText";
TeacherText.Bounds = new RectangleF(0, 0, Units.Millimeters * 59, Units.Millimeters * 7f);
TeacherText.Text = "[a.ID]";
TeacherText.Font = new Font("Tahoma", 11, FontStyle.Bold);
databand1.Objects.Add(TeacherText);
DataBand Databand2 = new DataBand();
Databand2.Name = "Data2";
Databand2.Height = Units.Centimeters * 0.5f;
Databand2.DataSource = report.GetDataSource("b");
TextObject PupilText = new TextObject();
PupilText.Name = "PupilText";
PupilText.Bounds = new RectangleF(0, 0, Units.Millimeters * 59, Units.Millimeters * 7f);
PupilText.Text = "[b.Row]";
PupilText.Font = new Font("Tahoma", 10, FontStyle.Regular);
Databand2.Objects.Add(PupilText);
databand1.AddChild(Databand2);
report.Show();
output:
1
detail11
detail12
detail21
detail22
2
detail11
detail12
detail21
detail22
how can I create relation and Ouput:
1
detail11
detail12
2
detail21
detail22
my code is:
DataSet dataset = new DataSet();
DataTable dt1 = new DataTable("dt1");
DataTable dt2 = new DataTable("dt2");
dt1.Columns.Add("ID");
dt1.Columns.Add("Row");
dt2.Columns.Add("ID");
dt2.Columns.Add("Row");
dt1.Rows.Add("1", "parent1");
dt1.Rows.Add("2", "parent2");
dt2.Rows.Add("1", "detail11");
dt2.Rows.Add("1", "detail12");
dt2.Rows.Add("2", "detail21");
dt2.Rows.Add("2", "detail22");
dataset.Tables.Add(dt1);
dataset.Tables.Add(dt2);
System.Data.DataColumn parentColumn = dataset.Tables[0].Columns["ID"];
System.Data.DataColumn childColumn = dataset.Tables[1].Columns["ID"];
DataRelation dataRel = new DataRelation("parent2Child", parentColumn, childColumn);
dataset.Tables[1].ParentRelations.Add(dataRel);
/////////////////////////////////////////
Report report = new Report();
report.Load("PmPlanReportIdentityF.frx");
report.RegisterData(dataset, "ds");
report.RegisterData(dataset.Tables["dt1"], "a");
report.RegisterData(dataset.Tables["dt2"], "b");
report.GetDataSource("a").Enabled = true;
ReportPage page1 = new ReportPage();
page1.Name = "Page1";
report.Pages.Add(page1);
page1.ReportTitle = new ReportTitleBand();
page1.ReportTitle.Name = "ReportTitle1";
page1.ReportTitle.Height = Units.Millimeters * 15f;
TextObject SchoolTitleText = new TextObject();
SchoolTitleText.Name = "SchoolTitle";
SchoolTitleText.Bounds = new RectangleF(0, 0,
Units.Centimeters * 19, Units.Centimeters * 1);
SchoolTitleText.Text = "NorthDale School";
SchoolTitleText.HorzAlign = HorzAlign.Left;
SchoolTitleText.Font = new Font("Tahoma", 14, FontStyle.Bold);
page1.ReportTitle.Objects.Add(SchoolTitleText);
GroupHeaderBand group1 = new GroupHeaderBand();
group1.Name = "GroupHeader1";
group1.Height = Units.Centimeters * 1;
group1.Condition = "[a.ID]";
page1.Bands.Add(group1);
group1.GroupFooter = new GroupFooterBand();
group1.GroupFooter.Name = "GroupFooter1";
group1.GroupFooter.Height = Units.Millimeters * 5;
DataBand databand1 = new DataBand();
databand1.Name = "Data1";
databand1.Height = Units.Centimeters * 0.5f;
databand1.DataSource = report.GetDataSource("a");
group1.Data = databand1;
TextObject TeacherText = new TextObject();
TeacherText.Name = "TeacherText";
TeacherText.Bounds = new RectangleF(0, 0, Units.Millimeters * 59, Units.Millimeters * 7f);
TeacherText.Text = "[a.ID]";
TeacherText.Font = new Font("Tahoma", 11, FontStyle.Bold);
databand1.Objects.Add(TeacherText);
DataBand Databand2 = new DataBand();
Databand2.Name = "Data2";
Databand2.Height = Units.Centimeters * 0.5f;
Databand2.DataSource = report.GetDataSource("b");
TextObject PupilText = new TextObject();
PupilText.Name = "PupilText";
PupilText.Bounds = new RectangleF(0, 0, Units.Millimeters * 59, Units.Millimeters * 7f);
PupilText.Text = "[b.Row]";
PupilText.Font = new Font("Tahoma", 10, FontStyle.Regular);
Databand2.Objects.Add(PupilText);
databand1.AddChild(Databand2);
report.Show();
output:
1
detail11
detail12
detail21
detail22
2
detail11
detail12
detail21
detail22
how can I create relation and Ouput:
1
detail11
detail12
2
detail21
detail22