Now I would like to programmatically create a master report that prints these labels as a SubReport on a DataBand with 3 columns.
Basically something like this, which causes a NullReferenceException:
Code: Select all
var labelTemplate = new StiReport().Load(mrtFileName);
var masterReport = new StiReport();
var dataBand = new StiDataBand
{
Name = "MasteDataBand",
Columns = 3,
Height = labelTemplate.Pages[0].Height
};
var subReport = new StiSubReport
{
Name = "LabelData",
Report = labelTemplate,
Width = labelTemplate.Pages[0].Width,
Height = labelTemplate.Pages[0].Height
};
dataBand.Components.Add(subReport);
masterReport.Pages[0].Components.Add(dataBand);
masterReport.RegBusinessObject("LabelData", new[]
{
new
{
ProductId = "Foo"
},
new
{
ProductId = "Bar"
},
});
masterReport.Dictionary.SynchronizeBusinessObjects();
masterReport.Design();