我正在尝试使用 Gridview 来显示来自 Object 数据源的数据表。它给了我错误:
ObjectDataSource 'odsStores' could not find a non-generic method 'ProcessDelete' that has parameters: ProcessID.
我已经阅读了很多关于匹配大小写、匹配格式、变量的问题的其他答案,但我认为我已经正确地完成了所有这些。这是aspx页面:
<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>
这是背后的代码,我所拥有的只是一个断点,它永远不会命中它。
<DataObjectMethod(DataObjectMethodType.Delete)> _
Private Sub ProcessDelete(ByVal ProcessID As String)
Dim x As Integer = 0
x = x + 1
End Sub
这是对象数据源:
<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>