Note that there are some explanatory texts on larger screens.

plurals
  1. POProper ObjectDataSource Use
    text
    copied!<p>Greetings!</p> <p>I'm creating a User Control that will display data in a GridView control. We are using n-tier architecture and the data in question is retrieved from our database and returned to us as a ReadOnlyCollection. OurNewObject is a class containing several properties and an empty constructor that takes no parameters - it's in the following namespace: Acme.ObjectModel.</p> <p>In the user control, I have the following:</p> <pre><code>&lt;asp:GridView ID="ourGrid" runat="server" DataSourceID="ourDataSource"&gt; &lt;columns&gt; &lt;asp:BoundField DataField="Name" HeaderText="Full Name" /&gt; &lt;asp:BoundField DataField="Gender" HeaderText="Gender" /&gt; &lt;asp:BoundField DataField="BirthYear" HeaderText="Year of Birth" /&gt; &lt;asp:BoundField DataField="JoinDate" HeaderText="Date Joined" /&gt; &lt;/columns&gt; &lt;/asp:GridView&gt; &lt;asp:ObjectDataSource ID="ourDataSource" runat="server" SelectMethod="GetTopUsers" TypeName="Acme.Model.OurNewObject"&gt; &lt;/asp:ObjectDataSource&gt; </code></pre> <p>In the User Control's code behind, I have the following public method:</p> <pre><code>public ReadOnlyCollection&lt;OurNewObject&gt; GetTopUsers() { return (OurDataProxy.GetJustTheTopUsers()); } </code></pre> <p>When I place the User Control on a Web form and run it, I get the following message:</p> <p><strong>ObjectDataSource 'ourDataSource' could not find a non-generic method 'GetTopUsers' that has no parameters.</strong></p> <p>So my questions are:</p> <ol> <li>Am I using the ObjectDataSource incorrectly?</li> <li>Is there a more proper way to use the ObjectDataSource in this situation?</li> </ol> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload