ObjectDataSource: defining a class as a data component
Posted on: Tue Aug 24 14:49:45 -0700 2010. Updated on: Tue Aug 24 14:52:12 -0700 2010.
Category: .NET C#
Category: .NET C#
When you create a new object data source and you point it to a class, have you noticed the checkbox next to the dropdown that says only show data components? There is an easy way to make your classes show up if that is checked. Here's how:
[DataObjectAttribute]
public class MyDataClass
{
// optionally give a method type
[DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
public static List GetAllPeople()
{
// return your data
}
}
For more info: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataobjectattribute.aspx