实例类的绑定子属性导致 ObjectDataSource 上的 UpdateParameters 出现错误

发布于 2024-12-22 00:28:49 字数 1093 浏览 2 评论 0原文

我有一个类,上面有一个实例属性,如下所示

Public Class Security

Public Property UserData As User

End Class

当我使用 ObjectDataSource 绑定 GridView 时,以下语法用于绑定 Gridview 内的下拉列表,并且可以处理所有内容,但准备更新时记录:

<act:ComboBox ID="cbxEmpNames" runat="server" Width="278px" AutoPostBack="False"
DataSourceID="odsEmployeeNames" DataTextField="FullNameFNLM" 
DataValueField="ID" SelectedValue='<%# Bind("UserData.ID") %>'>

看到问题似乎出现是因为 ComboBox 有自己的 ObjectDataSource,名为 odsEmployeeNames,其 Key =“ID”。但是,GridView 有自己的 ObjectDataSource,并且所选的 ComboBox 值由 '<%# Bind("UserData.ID") %>' 绑定

我得到的错误如下:

ObjectDataSource 'odsAdminSecurity' 找不到具有参数的非通用方法“Save”:NameID、IsAdminUser、UserData.ID、ID。

Save 上的签名() 方法如下:

Public Sub Save(ID As Integer, ByVal NameID As Integer, ByVal IsAdminUser As Boolean)

它试图添加 UserData.ID 的绑定值,但该参数是“NameID”参数,并且它要求的 UserData.ID 应该是该值。我过去的做法是让两个 ObjectDataSource(ComboBox 和 Gridview)的键名称具有相同的名称(即两者的名称均为“NameID”)。

关于如何纠正这个问题有什么想法吗? 谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小情绪 2024-12-29 00:28:49

您的保存签名具有三个参数,而错误表明您有四个参数传递给您的方法。您可以发布调用代码以便我们仔细查看吗?具体来说,您在哪里调用 Save() 方法?

You're save signature has three parameters while the error is stating you have four parameters being passed to your method. Can you post the calling code so we can take a closer look? Specifically, where are you calling the Save() method?

暖风昔人 2024-12-29 00:28:49

好吧,我从来没有完全弄清楚这一点。修复方法是稍微修改类设计,以不使用子属性绑定到包含其自己的 ODS 的组合框。通过使员工组合的绑定值与 Save() 方法上的参数名称相匹配,一切正常。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文