Error ObjectDataSource could not find a non-generic method

久未见 提交于 2019-12-13 05:17:14

问题


My error: ObjectDataSource 'dsGenre' could not find a non-generic method 'GetGenre' that has no parameters.

My code:

<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>

Why the error and how do I correct it?


回答1:


You'll need to find the libros class and check if a GetGenre method exists anywhere inside of it. For all we know, it's possible that this "libros" isn't accessible here. If you can't find a GetGenre method, try creating it inside the libros class. You'll probably have some more coding to do to get data to pull back but at least it might get rid of your current error and getting you closer to your goal. There's more information about ObjectDataSource here.

Also, it could be that you need to put the fully qualified class name in. It's hard to say without seeing more of the code.



来源:https://stackoverflow.com/questions/19193448/error-objectdatasource-could-not-find-a-non-generic-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!