Gets or sets the name of the method or function that the System.Web.UI.WebControls.ObjectDataSource control invokes to retrieve data.
Documentation for this section has not yet been entered.
The specified method can have any method signature, but it must return one of the types shown in the following table for the System.Web.UI.WebControls.ObjectDataSource control to call it successfully.
IEnumerable |
The IEnumerable is returned by the ObjectDataSource.Select method. |
System.Data.DataTable |
A System.Data.DataView is created using the System.Data.DataTable and returned by the ObjectDataSource.Select method. |
System.Data.DataView |
A System.Data.DataView is returned by the ObjectDataSource.Select method. |
System.Data.DataSet |
The first System.Data.DataTable of the System.Data.DataSet is extracted, and a System.Data.DataView is created and returned by the ObjectDataSource.Select method. |
object |
The object is wrapped in a one-element IEnumerable collection and returned by the ObjectDataSource.Select method. |
The ObjectDataSource.SelectMethod property delegates to the ObjectDataSourceView.SelectMethod property of the System.Web.UI.WebControls.ObjectDataSourceView object that is associated with the System.Web.UI.WebControls.ObjectDataSource control.
When you use the System.Web.UI.WebControls.ObjectDataSource class to delete or update data, make sure that the parameter names configured for the System.Web.UI.WebControls.ObjectDataSource control in the ObjectDataSource.DeleteParameters collection or ObjectDataSource.UpdateParameters collection match the column names that are returned by the select method.
The method that is identified by the ObjectDataSource.SelectMethod property can be an instance method or a static (Shared in Visual Basic) method. If it is an instance method, the business object is created and destroyed each time the method that is specified by the ObjectDataSource.SelectMethod property is called. You can handle the ObjectDataSource.ObjectCreated and ObjectDataSource.ObjectCreating events to work with the business object before the method that is specified by the ObjectDataSource.SelectMethod property is called. You can also handle the ObjectDataSource.ObjectDisposing event that is raised after the method that is specified by the ObjectDataSource.SelectMethod property is called. If the business object implements the IDisposable interface, the IDisposable.Dispose method is called before the object is destroyed. If the method is static (Shared in Visual Basic), the business object is never created and you cannot handle the ObjectDataSource.ObjectCreated, ObjectDataSource.ObjectCreating, and ObjectDataSource.ObjectDisposing events.
Parameters are added to the ObjectDataSource.SelectParameters collection from these sources:
Declaratively from the SelectParameters element.
Programmatically from the Selecting method.
First, the parameters listed in the SelectParameters element are added. Second, parameters are programmatically added and removed in the ObjectDataSource.Selecting event, which occurs before the ObjectDataSource.Select method is run. The method is resolved after the parameters are merged. Method resolution is discussed in the next section.
You should validate any parameter value that you receive from the client. The runtime simply substitutes the parameter value into the ObjectDataSource.SelectMethod property.
When the ObjectDataSource.Select method is called, the data fields from the data-bound control, the parameters that were created declaratively in the SelectParameters element, and the parameters that were added in the ObjectDataSource.Selecting event handler are all merged. (For more information, see the preceding section.) The System.Web.UI.WebControls.ObjectDataSource control then attempts to find a method to call. First, it looks for one or more methods with the name that is specified in the ObjectDataSource.SelectMethod property. If no match is found, an InvalidOperationException exception is thrown. If a match is found, it then looks for matching parameter names. For example, suppose a type that is specified by the ObjectDataSource.TypeName property has two methods named SelectARecord. One SelectARecord has one parameter, ID, and the other SelectARecord has two parameters, Name and Number. If the ObjectDataSource.SelectParameters collection has only one parameter named ID, the SelectARecord method with just the ID parameter is called. The type of the parameter is not checked in resolving the methods. The order of the parameters does not matter.
If the ObjectDataSource.DataObjectTypeName property is set, the method is resolved in a different way. The System.Web.UI.WebControls.ObjectDataSource looks for a method with the name that is specified in the ObjectDataSource.SelectMethod property that takes one parameter of the type that is specified in the ObjectDataSource.DataObjectTypeName property. In this case, the name of the parameter does not matter.