I have a class that has an instance property on it like below
Public Class Security
Public Property UserData As User
End Class
When I bind a GridView using an ObjectDataSource, the following syntax is used to bind a dropdown within the Gridview and works for everything but when ready to Update the record:
<act:ComboBox ID="cbxEmpNames" runat="server" Width="278px" AutoPostBack="False"
DataSourceID="odsEmployeeNames" DataTextField="FullNameFNLM"
DataValueField="ID" SelectedValue='<%# Bind("UserData.ID") %>'>
See the problem seems to arise because the ComboBox has its own ObjectDataSource named odsEmployeeNames with a Key = “ID”. However the GridView has its own ObjectDataSource and the ComboBox value selected is bound by ‘<%# Bind(“UserData.ID”) %>’
The resulting error I get is as follows:
ObjectDataSource ‘odsAdminSecurity’ could not find a non-generic method ‘Save’ that has parameters: NameID, IsAdminUser, UserData.ID, ID.
The signature on the Save() method is as follows:
Public Sub Save(ID As Integer, ByVal NameID As Integer, ByVal IsAdminUser As Boolean)
It is trying to add in that bound value of UserData.ID, but that paramter is the “NameID” parameter and the UserData.ID it is asking for should be that value. The way I have gotten by this in the past is to have the key name for both ObjectDataSources (ComboBox and Gridview) have the same name (i.e. both are name ‘NameID’).
Any ideas on how to correct this?
Thanks!
Well I never totally figured this out. The fix was to modify the class design a bit to not use the child properties for binding to the combo box that contained its own ODS. By having the bound value for the employee combo match the parameter name on the Save() method, everything worked fine.