0
votes

I have a list view with 5 columns which is populated via a stored procedure. That is displaying fine. I also have a Delete method which only takes in one int (the ID) but I am not sure how to define this method in the dataSource of the listview.

I keep getting an error that there is no Delete method which takes in 5 paramteres (the listview's column names) which of course there isn't. There is one which takes in 1 int parameter, see below.

I think there must be some error with the DataSource Delete method declaration, can anyone tell?

<asp:ObjectDataSource ID="userListDataSource" runat="server" 
            SelectMethod="GetUserList" TypeName="UserManagerBO" 
            DeleteMethod="DeleteUser">
            <DeleteParameters>
                <asp:Parameter Name="userID" Type="Int32"/>
            </DeleteParameters>
        <SelectParameters>
            <asp:ControlParameter DefaultValue="61" Name="userID" Type="Int32" 
                ControlID="lbUsers" PropertyName="SelectedValue" />
        </SelectParameters>
</asp:ObjectDataSource>

The method to delete is DeleteUser(int userID) and it seems to always look at the SelectParameters, even for my Delete method.

1

1 Answers

0
votes

Try dont provide parameter to the deletemethod, by doing this you can get the entire object selected for delete as a parameter. In Delete method,

Public Void DeleteUser(User usr)
{
        //delete user of usr.UserID
}