Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Passing Variables via ObjectDataSource

Status
Not open for further replies.

raphael232

Programmer
Joined
Jun 9, 2006
Messages
51
Location
GB
This is an update on my original post, after a little research i have descovered that pass a variable number of parameters into a method/function you use ParamArray, ie:

Code:
Public Function UpdateDocument(ByVal title As String, ByVal documentID As Integer, ByVal ParamArray list As Object()) As Boolean
        DocumentsAdapter.Update(title, documentID)

        ' handle additional parameters

        Return True
    End Function

In my web form page i have:

Code:
<asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="ObjectDataSource1"
        Height="50px" Width="125px">
        <Fields>
            <asp:CommandField ShowEditButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeleteDocument"
        InsertMethod="InsertDocument" OldValuesParameterFormatString="original_{0}" SelectMethod="GetDocumentByID"
        TypeName="DocumentManager" UpdateMethod="UpdateDocument">
        <DeleteParameters>
            <asp:Parameter Name="documentID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="title" Type="String" />
            <asp:Parameter Name="documentID" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="1" Name="documentID" QueryStringField="ID"
                Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:Parameter Name="title" Type="String" />
        </InsertParameters>
    </asp:ObjectDataSource>

and when i run the application my title appears, along with any additional attributes which are sent in the getDocumentByID method but when i edit the record i recieve the following error:

ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'UpdateDocument' that has parameters: title, documentID, Attribute 1, Attributes 2.

I'm sure it's something trivial i'm missing. Appreciate your help. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top