Greetings!
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.
In the user control, I have the following:
<asp:GridView ID="ourGrid" runat="server" DataSourceID="ourDataSource">
<columns>
<asp:BoundField DataField="Name" HeaderText="Full Name" />
<asp:BoundField DataField="Gender" HeaderText="Gender" />
<asp:BoundField DataField="BirthYear" HeaderText="Year of Birth" />
<asp:BoundField DataField="JoinDate" HeaderText="Date Joined" />
</columns>
</asp:GridView>
<asp:ObjectDataSource ID="ourDataSource" runat="server" SelectMethod="GetTopUsers" TypeName="Acme.Model.OurNewObject">
</asp:ObjectDataSource>
In the User Control's code behind, I have the following public method:
public ReadOnlyCollection<OurNewObject> GetTopUsers()
{
return (OurDataProxy.GetJustTheTopUsers());
}
When I place the User Control on a Web form and run it, I get the following message:
ObjectDataSource 'ourDataSource' could not find a non-generic method 'GetTopUsers' that has no parameters.
So my questions are:
- Am I using the ObjectDataSource incorrectly?
- Is there a more proper way to use the ObjectDataSource in this situation?
Thanks.