I have some code that is going to be used in several places in my project, and it is an ideal candidate for a UserControl. It is a search/results form. It uses an ObjectDataSource to get the results from the search criteria.
I set the properties of the ODS at runtime, in the Page_Load of the control and in the Page_Load of the host page. When the host page loads up, there are no errors, but when I run the search, I get the error, "
ObjectDataSource 'odsSelector' could not find a non-generic method 'GetUnapprovedCases' that has parameters: UserCenterID, SearchType, UserCenterID1, SearchType1.".
UserCenterID1 and SearchType1 do not exist. What gives? I have a feeling I am close to the answer here, but it eludes me. Thanks in advance for your comments.
The Page_Load of the control looks like this:
Code:
Private Shared SearchText As String = ""
Private Shared ClassName As String
Private Shared MethodName As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With odsSelector
.SelectParameters.Add("UserCenterID", TypeCode.Int32, Session("UserCenterID"))
.SelectParameters.Add("SearchType", TypeCode.String, Trim(txtSearchTypeValue.Text))
.SelectParameters("SearchType").DefaultValue = "LastName"
.TypeName = ClassName
.SelectMethod = MethodName
End With
End Sub
The values for ClassName and MethodName are passed in the Host page's load event.