'ObjectDataSource1'找不到具有参数的非泛型方法'getCOMDLs':

时间:2010-09-27 18:13:13

标签: vb.net gridview objectdatasource

收到此错误消息,我无法弄清楚原因。这是我的代码:

<asp:TextBox ID="searchParam" Width="250px" runat="server"></asp:TextBox><asp:button ID="btnSearch" runat="server" Text="Search" />
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="getCOMDLs" TypeName="NewEmployee">
    <SelectParameters>
        <asp:FormParameter FormField="searchParam" Type="String" DefaultValue="" />
    </SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="dgSearchDLs" runat="server" DataKeyNames="cn" AllowPaging="false" DataSourceID="ObjectDataSource1">
    <Columns>
        <asp:BoundField DataField="cn" HeaderText="DL Name"/>
        <asp:BoundField DataField="managedBy" HeaderText="Managed By"/>
        <asp:BoundField DataField="info" HeaderText="Notes"/>
        <asp:ButtonField ButtonType="Button" text="Add" HeaderText = "Select DL" CommandName="AddDL"  />
    </Columns>
</asp:GridView>

NewEmployee Class:

Function getCOMDLs(ByVal searchParam As String) As DataTable
    ...
End Function

1 个答案:

答案 0 :(得分:0)

在研究了这个问题/试错之后,解决方案是将Name =“searchParam”添加到表单参数控件中。