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#

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

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.