为什么数据绑定在第二次时不起作用?
当我更改 BindingSource 的数据源时出现错误
“数据绑定无法找到适合所有绑定的行。适用于所有绑定的行”
this.RemoveAllBindings(); // My work-around for the meantime
bdsOrder.DataSource = _ds.Tables["orders"]; // errors here on second time around(first time is blank datatable, second time is when i open existing record, then it errors), dataset comes from Remoting
bdsOrderDetail.DataSource = _ds.Tables["order_detail"];
bdsPhoto.DataSource = _ds.Tables["order_photo"];
bdnPhoto.BindingSource = bdsPhoto;
我的帮助器扩展方法解决了令人困惑的“数据绑定无法找到行...”错误。
namespace MycComponentExtension
{
public static class Helper
{
public static void RemoveAllBindings(this Form form)
{
RemoveAllBindings((Control)form);
}
private static void RemoveAllBindings(this Control root)
{
foreach (Control c in root.Controls)
{
if (c.Controls.Count > 0) RemoveAllBindings(c);
root.DataBindings.Clear();
}
}
“DataBinding 找不到行...”错误是什么意思,如果可能的话,我可以消除它的解决方法吗?
The error I got when I change the datasource of BindingSource
"databinding cannot find a row that is suitable for all bindings row that is suitable for all bindings"
this.RemoveAllBindings(); // My work-around for the meantime
bdsOrder.DataSource = _ds.Tables["orders"]; // errors here on second time around(first time is blank datatable, second time is when i open existing record, then it errors), dataset comes from Remoting
bdsOrderDetail.DataSource = _ds.Tables["order_detail"];
bdsPhoto.DataSource = _ds.Tables["order_photo"];
bdnPhoto.BindingSource = bdsPhoto;
My Helper extension method work-around on perplexing "databinding cannot find a row..." error.
namespace MycComponentExtension
{
public static class Helper
{
public static void RemoveAllBindings(this Form form)
{
RemoveAllBindings((Control)form);
}
private static void RemoveAllBindings(this Control root)
{
foreach (Control c in root.Controls)
{
if (c.Controls.Count > 0) RemoveAllBindings(c);
root.DataBindings.Clear();
}
}
What's the meaning of "DataBinding cannot find a row..." error, if at all possible, can I eliminate my work-around on it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当不涉及 DataGridView 时,我看到了此错误,但我的数据源正在从另一个线程更新(顽皮!)并且我的绑定具有 FormattingEnabled=false。 改变这两个似乎可以解决问题。
I have seen this error when no DataGridView is involved, but my data source was being updated from another thread (naughty!) and my binding had FormattingEnabled=false. Changing both of these seemed to fix the problem.