I'm using Gridview with objectdatasource, I've selected select and delete method for objectdatasource, but i don't know how to set delete parameter (id) for objectdatasource. here is my code:
<apc:GridView ID="GridView1" runat="server" ApproveText="APPROVE" AutoGenerateColumns="False" CancelText="Canecl" CheckAllText="CHECK All" DataSourceID="ObjectDataSource1" DeleteAllText="Delete Selected Rows" DeleteButtonImageUrl="css/layout/site/tables/action4.gif" DeleteText="Delete" EditText="Edit" NewText="ADD NEW" SelectButtonImageUrl="css/layout/site/tables/action1.gif" SelectText="Select" ShowCheckBox="True" ShowDeleteAllButton="True" ShowDeleteButton="True" ShowEditButton="True" ShowNewButton="False" ShowSelectButton="True" Title="Table Template" UnCheckAllText="UNCHECK All" UpdateText="Update" DataKeyNames="Id" >
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName" />
<asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber" SortExpression="PhoneNumber" />
<asp:BoundField DataField="MobileNumber" HeaderText="MobileNumber" SortExpression="MobileNumber" />
<asp:BoundField DataField="CompanyPhone" HeaderText="CompanyPhone" SortExpression="CompanyPhone" />
<asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
</Columns>
i get ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Delete' that has parameters: id, original_Id. please help me. tanks.
It looks like you need to modify your delete method to accept an
Id
parameter. I had a similar issue where I wasn't setting theDataKeyNames
property and once I did I got the same error as you. I resolved the issue by adding theId
as a parameter to my function.