Hi, I'm having trouble binding my formview to an ods. The error is:
"ObjectDataSource 'ClientsDataSource' could not find a non-generic method 'GetAllClients' that has no parameters."
I've double checked spelling, tried adding/removing DataKeyNames property and few other with no luck. The only time it works is if I bind to a detailsview and leave the bound columns untouched, but this is not what I want.
here is my code:
Public Function GetAllCients() As IEnumerable(Of Client)
Dim AllClients = (From c In context.Clients
Order By c.LastName
Select c).ToList()
Return AllClients
End Function
juan03
Member
1 Points
11 Posts
ObjectDataSource with FormView Issue
Jan 26, 2013 09:27 PM|LINK
Hi, I'm having trouble binding my formview to an ods. The error is:
"ObjectDataSource 'ClientsDataSource' could not find a non-generic method 'GetAllClients' that has no parameters."
I've double checked spelling, tried adding/removing DataKeyNames property and few other with no luck. The only time it works is if I bind to a detailsview and leave the bound columns untouched, but this is not what I want.
here is my code:
Public Function GetAllCients() As IEnumerable(Of Client) Dim AllClients = (From c In context.Clients Order By c.LastName Select c).ToList() Return AllClients End Functionand markup:
<asp:ObjectDataSource ID="ClientsDataSource" runat="server" SelectMethod="GetAllClients" TypeName="DAL" EnableCaching="true" CacheDuration="30"> </asp:ObjectDataSource><asp:FormView ID="clientsFormView" runat="server" AllowPaging="True" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" DataKeyNames="ClientId" DataSourceID="ClientsDataSource"> <ItemTemplate> Contact:<br /><br /> <asp:Label ID="clientid" Text='<%# Bind("ClientId") %>' runat="server"></asp:Label> Name:<br /> <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("FullName") %>'></asp:TextBox> <br /> Phone:<br /> <asp:TextBox ID="txtPhone" runat="server" Text='<%# Bind("Phone") %>'></asp:TextBox> <br /> Email:<br /> <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox> </ItemTemplate> <EmptyDataTemplate> <h2>No Data</h2> </EmptyDataTemplate> <EditRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" /> <FooterStyle CssClass="ClientDetailsFooter" /> <HeaderStyle CssClass="ClientDetailsHeader" /> <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /> <RowStyle BackColor="White" ForeColor="#003399" /> </asp:FormView>any help would be appreciated.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: ObjectDataSource with FormView Issue
Jan 28, 2013 12:59 AM|LINK
Hi,
Your codes look nice……So please re-build your program and have a try again.
Problem may be your UI isn't synchronized with your codes, so it cannot be recognized.