I created class inherited from DataTable. I want to Expose the items like “Name” , “Number”
from the class. Just like this
class MyClass : DataTable
{
[Column]
Name
[Column]
Number
}
so that i can access like row[“Name”] = “some”;
and i going to use this data table as DataSource to Crystal Report. ( ie from Data menu->Add new DataSource –> object and select the appropriate class and this will display the Name and Number which i can add to crystal report at design time)
How to achieve this.
You are reinventing the wheel. Trying to create a DataTable that will expose named rows/columns is a pattern that has already been done in .NET 2.0 – If you’re using .NET 2.0 take a look at this MSDN tutorial which goes through creating Strongly Typed DataSets.
You can also search on google for more information using the keywords Strong Typed DataSets