Thursday, July 23, 2009

C# - Error Message - 'This would cause two bindings in the collection to bind to the same property'

It shows the code is calling Control.DataBindings.Add two times to the same parameters.
May be duplicate binding to the DataBindings collection causes this error. Anyway one
solution is to clear Control.DataBindings before adding new binding:


this.txtAddress.DataBindings.Clear();
this.txtZipCode.DataBindings.Clear();

this.txtAddress.Text = string.Empty;
this.txtZipCode.Text = string.Empty;

this.txtAddress.DataBindings.Add("Text", myDtaTbl, "Address");
this.txtZipCode.DataBindings.Add("Text", myDtaTbl, "ZipCode");

Share/Bookmark

No comments: