【问题标题】:Error ObjectDataSource could not find a non-generic method错误 ObjectDataSource 找不到非泛型方法
【发布时间】:2013-10-05 02:49:47
【问题描述】:

我的错误:ObjectDataSource 'dsGenre' 找不到没有参数的非泛型方法 'GetGenre'。

我的代码:

<asp:DropDownList runat="server" ID="genreList" style="float:left;" DataSourceID="dsGenre" DataTextField="Author_Name" DataValueField="title_id" />
<asp:ObjectDataSource runat="server" ID="dsGenre" SelectMethod="GetGenre" TypeName="libros" />
<asp:SqlDataSource runat="server" ID="sqlGenres" ConnectionString="<%$ ConnectionStrings:library %>" ProviderName="<%$ ConnectionStrings:library.ProviderName %>" SelectCommand="get_allGenres" SelectCommandType="StoredProcedure"> 
  <SelectParameters>
    <asp:QueryStringParameter Name="genre_id" Type="Int32" QueryStringField="id" />
  </SelectParameters>
</asp:SqlDataSource>

为什么会出现错误以及如何更正?

【问题讨论】:

  • 好吧,我要问:你有没有没有参数的非泛型方法'GetGenre'?
  • 你能用GetGenre代码更新问题吗?
  • 这就是页面上的所有代码。我应该解决错误。 t
  • 以前的开发人员试图调用一个存储过程,该过程将在一个组合框中列出来自对 sql 数据库的调用的标题类型。

标签: c# asp.net objectdatasource


【解决方案1】:

您需要找到libros 类并检查其中是否存在GetGenre 方法。据我们所知,这里可能无法访问这个“libros”。如果找不到 GetGenre 方法,请尝试在 libros 类中创建它。您可能需要进行更多编码才能使数据回退,但至少它可能会消除您当前的错误并让您更接近目标。有more information about ObjectDataSource here.

此外,您可能需要将完全限定的类名放入其中。如果不看更多代码,很难说。

【讨论】:

  • 感谢有关对象数据源的链接。另一个开发人员退出了,因为我知道 vb,所以经理认为我可以快速解决这个问题。哈哈。我有一些阅读要做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-21
  • 2011-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多