物件資料來源

<asp:ObjectDataSource ID="ObjectDataSourceEmployees" runat="server"
    TypeName="MyPackage.MyDataAccessClass"                       
    DataObjectTypeName="MyPackage.Employee" 
    SelectMethod="GetEmployees"
    UpdateMethod="SaveEmployee"
    InsertMethod="SaveEmployee">
</asp:ObjectDataSource>

在後面的程式碼中

資料訪問類

public class MyDataAccess
{
    public static List<Employee> GetEmployees()
    {
        List<Employee> results = new List<Employee>()
        {
            new Employee(){ Id=1, Name="John Smith" }, 
            new Employee(){ Id=2, Name="Mary Jane" } 
        };
    
        return results;
    }  

    public static void SaveEmployee(Employee e)
    {
        // Persist Employee e to the DB/cache etc. here
    }        
}

員工類

public class Employee
{
    public Int32EmployeeId { get; set; }
    public string Name { get; set; }
}