Hello,
I am using the latest evaluation version of Telerik Report Control. I am running into a problem where I have to get data from two different objects and then combine them into a single DataSource object. Here's my problem in detail:
1. In the code below, I have two classes A and G that get data from two different data sources. Either of them or both can be null.
2. I want my Telerik report to read both the data sources and then print the results. However, since I cannot define two different data sources to a single report, I thought of combining them into a bigger class and making that class as a DataSource to the report.
3. The class ReportData serves as a container class that holds a List of the two types of objects, A and G.
4. I then return the ReportData object from TheData class. The TheData class is defined as the ObjectDataSource for the Telerik report.
5. When I go to the designer to attach my data source fields, I am getting the intellisense and the report designer is able to detect the class hierarchy and lets me set the binding to "= Fields.a.Item.Name". However, when I try to run this report in the Preview mode, I am getting an error "An error has occured processing TextBox "textBox1". Common language runtime detected an invalid program.
I have tried quite a few options here but nothing seems to work. I cannot control how I receive the data so I need to combine the two objects somehow at my end and feed them to my Report.
Any help would be greatly appreciated.
Thanks.
[DataObjectAttribute]
class TheData
{
[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
public ReportData GetData()
{
ReportData X = new ReportData();
X.Init();
return X;
}
}
class ReportData
{
public List<A> a { get; set; }
public List<G> g { get; set; }
public void Init()
{
a = new List<A>();
g = new List<G>();
A TheA1 = new A();
TheA1.Name = "A1";
A TheA2 = new A();
TheA2.Name = "A2";
G TheG1 = new G();
TheG1.ID = "G1";
G TheG2 = new G();
TheG2.ID = "G2";
a.Add(TheA1);
a.Add(TheA2);
g.Add(TheG1);
g.Add(TheG2);
}
}
public class A
{
public string Name { get; set; }
}
public class G
{
public string ID { get; set; }
}
I am using the latest evaluation version of Telerik Report Control. I am running into a problem where I have to get data from two different objects and then combine them into a single DataSource object. Here's my problem in detail:
1. In the code below, I have two classes A and G that get data from two different data sources. Either of them or both can be null.
2. I want my Telerik report to read both the data sources and then print the results. However, since I cannot define two different data sources to a single report, I thought of combining them into a bigger class and making that class as a DataSource to the report.
3. The class ReportData serves as a container class that holds a List of the two types of objects, A and G.
4. I then return the ReportData object from TheData class. The TheData class is defined as the ObjectDataSource for the Telerik report.
5. When I go to the designer to attach my data source fields, I am getting the intellisense and the report designer is able to detect the class hierarchy and lets me set the binding to "= Fields.a.Item.Name". However, when I try to run this report in the Preview mode, I am getting an error "An error has occured processing TextBox "textBox1". Common language runtime detected an invalid program.
I have tried quite a few options here but nothing seems to work. I cannot control how I receive the data so I need to combine the two objects somehow at my end and feed them to my Report.
Any help would be greatly appreciated.
Thanks.
[DataObjectAttribute]
class TheData
{
[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
public ReportData GetData()
{
ReportData X = new ReportData();
X.Init();
return X;
}
}
class ReportData
{
public List<A> a { get; set; }
public List<G> g { get; set; }
public void Init()
{
a = new List<A>();
g = new List<G>();
A TheA1 = new A();
TheA1.Name = "A1";
A TheA2 = new A();
TheA2.Name = "A2";
G TheG1 = new G();
TheG1.ID = "G1";
G TheG2 = new G();
TheG2.ID = "G2";
a.Add(TheA1);
a.Add(TheA2);
g.Add(TheG1);
g.Add(TheG2);
}
}
public class A
{
public string Name { get; set; }
}
public class G
{
public string ID { get; set; }
}