我試圖使用Gridview來顯示來自Object數據源的數據表。它給我的錯誤:ObjectDataSource找不到具有參數的非泛型方法:
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>
你可以發佈'
@KarlAnderson,補充說,對不起,我最初沒有發佈。 – gbam
我有點在黑暗中拍攝,但我在MSDN上看到這個,注意到'ObjectDataSource'控件上的'typename'屬性:typename =「Samples.AspNet.CS.EmployeeLogic」。你是否忽略了'typename'出於任何原因,如果是這樣,當你省略typename這裏是數據源尋找方法的默認位置? –