Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why DataBinding doesn't work on second time around?

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?

like image 796
Hao Avatar asked Mar 25 '09 03:03

Hao


People also ask

What are the different of data binding and simple data binding?

You also learned that there are two types of data binding as in the following: Simple Data binding: the process of binding a control such as a TextBox or a label. Complex data binding: the process of binding a control such as ComboBox, DataGridView, or ListBox.

What is the purpose of data binding?

Data binding is the process that establishes a connection between the app UI and the data it displays. If the binding has the correct settings and the data provides the proper notifications, when the data changes its value, the elements that are bound to the data reflect changes automatically.

What is Databind in Ado net?

Data Binding Using ADO.NET. Client-Server development. Data Binding. The process of automatically setting properties of one or more form controls at run time from a structure that contains data.

What is databinding in VB net?

Description. Simple data binding. The ability of a control to bind to a single data element, such as a value in a column in a dataset table. Simple data binding is the type of binding typical for controls such as a TextBox control or Label control, which are controls that typically only display a single value.


1 Answers

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.

like image 76
Mark Foreman Avatar answered Sep 27 '22 01:09

Mark Foreman