ReportXmlSerializer().Serialize() throws unexpected System.ArgumentException:
'Invalid name character in 'MyData[]'. The '[' character, hexadecimal value 0x5B, cannot be included in a name.'
- Or -
What other way can I save the data with the report?
private void CreateReport() {
var report = new Telerik.Reporting.Report();
report.Name = "MyReport";
var detail = new Telerik.Reporting.DetailSection();
report.Items.Add(detail);
var textBox = new Telerik.Reporting.TextBox();
textBox.Value = "Hello World!";
detail.Items.Add(textBox);
var dataSource = new ObjectDataSource();
dataSource.Name = "MyData";
dataSource.DataSource = MyData.Sample;
report.DataSource = dataSource;
var reportPath = @"C:\develop\Temp\MyReport.trdp";
new ReportXmlSerializer().Serialize(reportPath, report);
}
public class MyData {
public static readonly MyData[] Sample = { new() { Text = "Foo", Number = 42 }, new() { Text = "Bar", Number = 21 } };
public string Text { get; set; }
public int Number { get; set; }
}