数据绑定失败

发布于 2024-07-23 07:52:59 字数 385 浏览 12 评论 0原文

我有一个包含 30 个数据字段的表单 - 主要是显示字符串数据的 TextBox 控件,但有 3 个下拉列表组合框和一个用于显示日期时间的文本框。 我使用 BindingSource 将这些字段绑定到从 BindingList<> 派生的自定义数据对象。

根据数据源中数据的内容,有时特定字段将无法绑定 - 这意味着来自数据源的数据不会移动到控件。 失败的控件是一个简单的 textbox.text / string 绑定。

我可以执行一个特定的查询,该查询在每个实例中都会导致该特定字段无法绑定。 我还有其他可以执行的查询,这些查询会生成一组数据,其中绑定都可以完美运行。

我的问题是 - 是什么导致数据绑定失败? 其他某个绑定字段的失败是否会阻止所有其他绑定触发?

I have a form with 30 fields of data on it - mostly TextBox controls displaying string data, but there are 3 dropdownlist comboboxes and one textbox used to display a datetime. I'm using a BindingSource to bind these fields to a custom data object derived from BindingList<>.

Depending on the content of the data in the data source, sometimes a specific field will simply fail to bind - meaning the data from the data source does not get moved to the control. The control that fails is a simple textbox.text / string binding.

I can perform a specific query that in every instance will cause this specific field to fail to bind. I have other queries that can be performed that produce a set of data where the bindings all work perfectly.

My question is - what causes data binding to fail? Will the failure of some other bound field stop all the other bindings from firing?

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

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

发布评论

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

评论(2

东京女 2024-07-30 07:52:59

您可以检查以下几项内容:

  • 数据字段的大小与 UI 中的字段大小是否不匹配
  • 数据中是否有任何特殊字符
  • 绑定字段的代码是否在某些情况下未运行
  • 是否有一些清除绑定的代码

Here are a few things that you could check

  • Is there a mismatch in the size of the data field and the field in the UI
  • Are there any special characters in the data
  • Is the code that binds the fields not being run in certain circumstances
  • Is there some code that is clearing the binding
暗喜 2024-07-30 07:52:59

我通过编写自己的绑定基础结构解决了这个问题。 这使我能够更明确地控制绑定何时触发以及结果发生的情况。

I solved this issue by writing my own binding infrastructure. That gave me more explicit control over when bindings fired and what happened as a result.

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