Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top