I am finding the documentation really complicated. How can I create a class to be used as an objectdatasource? When I ran the wizard I put in my class but it didn't show any of the fields. So here is my class. How can I turn this into an objectdatasource?
public class MyClass
{
public MyClass()
{ }
public Guid Id;
public string Name;
public string Description;
}
It's bigger than that, but that's the gist. I want to create a table that will list each of the items in a list of MyClass.
4 Answers, 1 is accepted
Properties must be accessible (e.g. public) with get and set methods - Data Explorer does not show all or any data fields.
Please check the DataBinding/ListboundReport example in the local demos, installed by default under C:\Program Files (x86)\Telerik\Reporting R3 2016\Examples.
Let us know if you need further help.
Regards,
Stef
Telerik by Progress
Hi Stef, that example has the objectDataSource as the Cars class and in that class you're hard coding data. I don't want to do that. I want to pass in a list of MyClass to the report that will then populate the table with the data. So this is what I have:
public class MyClass
{
Guid Id;
string name;
string description;
public MyClass(Guid id, string name, string description)
{
this.id = id;
this.name = name;
this.description = description;
}
public Guid Id
{
get { return this.id; }
set { this.id = value; }
}
public string Name
{
get { return this.name; }
set { this.name = value; }
}
public string Description
{
get { return this.description; }
set { this.description = value; }
}
}
However when I try creating an objectdatasource on the Choose a Data Member page of the wizard in the box all I get is MyClass() whether I select No data source member or Choose a data source member. So I just click on MyClass() and then Finish. It goes back to Choose a Data Source and then I click Next. Now it's asking me to Arrange Fields but in the list of Data Source Fields all it has is objectDataSource1 listed and nothing underneath it. I am totally stuck.
Just to add some details about the ObjectDataSource and how it works.
In general, the purpose of the ObjectDataSource component is to provide data to the report in a declarative manner. The ObjectDataSource.DataSource should be the assembly qualified name or Type of the data access layer (class), where the reporting engine will use System.Reflection to create the instance of the class (by using its default constructor) and to execute its method specified by the ObjectDataSource.DataMember property.
Regards,
Stef
Telerik by Progress