I have this model:
public class CustomerType
{
public int Id {get; set;}
public string Name {get; set;}
public string Description {get; set;}
}
Then, I have a binding source on a WinForms form, and its bound to existing object by doing:
var customerType = repository.Get(id);
bindingSource.DataSource = customerType;
I want to clear the datasource so I do:
bindingSource.DataSource = null;
But I get the following exception: Cannot bind to the property or column Name on the DataSource.
Setting the variable customerType
to null doesn't clear the datasource.
So what is the correct way to clear the datasource?