Saturday, February 04, 2006

Method Resolution

Method Resolution

When the 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 Selecting event handler are all merged. (For more information, see the preceding section.) The 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 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 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 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 DataObjectTypeName property is set, the method is resolved in a different way. The ObjectDataSource looks for a method with the name that is specified in the SelectMethod property that takes one parameter of the type that is specified in the DataObjectTypeName property. In this case, the name of the parameter does not matter.
this page

No comments: