public class NorthwindEmployee { public NorthwindEmployee() { } private int _empId; private string _firstName; public int EmpId { get { return _empId; } set { _empId = value; } } public string FirstName { get { return _firstName; } set { _firstName = value; } } // Additional code for the class. }Visual Basic
Public Class NorthwindEmployee Public Sub New() End Sub Private _empId As String Public Property EmpId() As Integer Get Return _empId End Get Set _empId = value End Set End Property Private _firstName As String Public Property FirstName() As String Get Return _firstName End Get Set _firstName = value End Set End Property ' Additional code for the class. End ClassTo accept an instance of the preceding class as a parameter, the business object's UpdateEmployeeInfo method might be defined using the following signature:
public void UpdateEmployeeInfo(NorthwindEmployee emp) {
}
Visual Basic Copy Code Public Sub UpdateEmployeeInfo(emp As NorthwindEmployee) End SubAlthough you cannot set the Type of a parameter to the name of a custom class, you can set the ObjectDataSource control's DataObjectTypeName property to the name of a custom user-defined type, such as the NorthwindEmployee class, and then pass an instance of the type to a business object data method. To pass user-defined objects to a data source object, the following conditions must be met:
<asp:objectdatasource runat="server" id="ObjectDataSource1" typename="EmployeeLogic" selectmethod="GetAllEmployees" updatemethod="UpdateEmployeeInfo" dataobjecttypename="NorthwindEmployee" />In some cases, the business object method will have a parameter list that contains multiple complex parameter types. In that case, you can use the ObjectDataSource control, but you must add your parameters to the ObjectDataSource control programmatically. To do this, handle the event that is raised before the data operation is performed, such as the Inserting, Updating, or Deleting event, and set values in the InputParameters collection exposed by the ObjectDataSourceMethodEventArgs class.