views:

563

answers:

1

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?

A: 

You'll have to provide a little more detail... what are the concrete types of the variables you have in your function?

Adam Robinson
:-) i thought otherwise that my description have enough detail. anyway, bdsOrder,bdsOrderDetail,bdsPhoto is a BindingSource type. _ds is a DataSet type, bdn is BindingNavigator
Hao