I'm trying to use a Gridview to show a datatable from an Object data source. It's giving me the error:
ObjectDataSource 'odsStores' could not find a non-generic method 'ProcessDelete' that has parameters: ProcessID.
I've read a lot of other answers to this question about matching case, matching format, variables but I think I've done all of those correctly. Here's the aspx page:
<asp:GridView ID="gridStores" runat="server" AllowSorting="False" AutoGenerateColumns="False"
CssClass="grid-main" DataSourceID="odsStores" EnableViewState="False" OnDataBound="gridStores_DataBound"
OnRowDataBound="gridStores_RowDataBound">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Image ID="imgModel" runat="server" AlternateText="Click to See Details" CssClass="img-details"
EnableViewState="False" ImageUrl="~/img/detail.gif" />
</ItemTemplate>
<ItemStyle CssClass="grid-main-detail" />
</asp:TemplateField>
<asp:BoundField DataField="ProcessID" HeaderText="ProcessID" />
<asp:BoundField DataField="ProcessName" HeaderText="Process Name" ReadOnly="False" />
<asp:BoundField DataField="ProcessDescription" HeaderText="Process Description" ReadOnly="False" />
<asp:BoundField DataField="UpdateUserID" HeaderText="Last Updated By" ReadOnly="True" />
<asp:BoundField DataField="UpdateTimestamp" HeaderText="Last Updated" ReadOnly="True" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
Here's the code behind, all I have is a break point and it never hits it.
<DataObjectMethod(DataObjectMethodType.Delete)> _
Private Sub ProcessDelete(ByVal ProcessID As String)
Dim x As Integer = 0
x = x + 1
End Sub
Here's the object datasource:
<asp:ObjectDataSource ID="odsStores" runat="server" EnableViewState="False" OldValuesParameterFormatString="original_{0}"
SelectCountMethod="GetRowCount" SelectMethod="GetData" TypeName="DataWarehouseUserInterface.ProcessBSL"
UpdateMethod="ProcessUpdate" DeleteMethod="ProcessDelete" >
<UpdateParameters>
<asp:FormParameter Name="ProcessName" Type="String" FormField="ProcessName" />
<asp:FormParameter Name="ProcessDescription" Type="String" FormField="ProcessDescription" />
</UpdateParameters>
<DeleteParameters>
<asp:FormParameter Name="ProcessID" Type="String"/>
</DeleteParameters>
</asp:ObjectDataSource>
My Object data source was looking in my ProcessBSL for a method called ProcessDelete with the corresponding signature. I had written my methods in the code behind ProcessBSL file.
This was the line of code that effected it:
TypeName="DataWarehouseUserInterface.ProcessBSL"
Summary: If it's throwing this error for you, ensure your method signature is correct. Ensure that the BSL layer is correct. Make sure you have _ - that also stopped mine from working. Hope this helps someone else.
Cheers.