Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

sql datasource select method

I get the following error, I am getting the value from the first drop down list departmentid.
Then passing this value to a stored procedure using the selectmethod of the second drop down list.

ObjectDataSource 'objdsAddColleague' could not find a non-generic method 'seladddepColleagueDetails' that has parameters: strConn, DepartmentID.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: ObjectDataSource 'objdsAddColleague' could not find a non-generic method 'seladddepColleagueDetails' that has parameters: strConn, DepartmentID.

My aspx page.
 
    <table id="tblDepartmentSelection" width="100%" border="0" style="border-bottom-width:1px; border-bottom-color:Black; border-bottom-style:solid" cellpadding="0" cellspacing="0" class="">
        <tr>
            <td align="center" style="height: 65px">
                <asp:DropDownList ID="ddlDepartment" runat="server" CssClass="" DataSourceID="objDepartmentDetails" Datatextfield="DepartmentName" DataValueField="DepartmentID" AutoPostBack="true">
                </asp:DropDownList>
                <asp:ObjectDataSource ID="objDepartmentDetails" runat="server" SelectMethod="GenericQuery" TypeName="WAB_DataAccessWS.WAB_DataAccessWS">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="hdnMainConnStr" Name="strConn" PropertyName="Value" Type="String"/>
                        <asp:Parameter defaultvalue="exec p_DepartmentDetails" name="strQuery" type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
        </tr>
    </table>
 
 
                <asp:DropDownList ID="ddlAddColleague" runat="server" CssClass="" DataSourceID="objdsAddColleague" DataValueField="ColleagueName" Datatextfield="ColleagueName" AutoPostBack="true">
                </asp:DropDownList>
                <asp:ObjectDataSource ID="objdsAddColleague" runat="server" SelectMethod="seladddepColleagueDetails" TypeName="WAB_DataAccessWS.WAB_DataAccessWS">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="hdnMainConnStr" Name="strConn" PropertyName="Value" Type="String"/>
                        <asp:ControlParameter ControlID="ddlDepartment" Name="DepartmentID" PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
 
 
My web service
    'Select add colleague
    <WebMethod()> _
    Public Function seladdColleagueDetails(ByVal strConn As String, ByVal DepartmentID As Integer) As Integer
        Return WAB_DataAccess.seladddepColleagueDetails(strConn, DepartmentID)
    End Function
 
My cls
 
    'Select method from webservice add colleaguedepartment
    Public Shared Function seladddepColleagueDetails(ByVal strConn As String, ByVal intDepartmentID As Integer) As Integer
        Using conn As New sqlconnection(strConn)
 
            Using cmd As New SqlCommand("p_AddColleague", conn)
                cmd.CommandType = CommandType.StoredProcedure
                cmd.Parameters.AddWithValue("DepartmentID", intDepartmentID)
                Try
                    conn.Open()
                    Return cmd.ExecuteNonQuery()
                Catch ex As Exception
                End Try
            End Using
 
        End Using
 
    End Function

Open in new window

0
aneilg
Asked:
aneilg
  • 2
1 Solution
 
sunithnairCommented:
Try replacing line 24 like this

                        <asp:ControlParameter ControlID="ddlDepartment" Name="intDepartmentID" PropertyName="SelectedValue" Type="Int32" />

Open in new window

0
 
aneilgAuthor Commented:
I think i mite have tried that i'll have a look in the morning.

Thanks for your help.

0
 
aneilgAuthor Commented:
Thanks for that i was calling seladddepColleagueDetails instead of seladdColleagueDetails
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now