views:

1010

answers:

0

Hi everyone,

I have some problems with the Datagridview, a Bindingsource for the datagrid with a datasource of a ADO.net Entity Framework ObjectEntity called categorie.

During runtime, and setting the BindingSource Controls property 'DataSource', I get this error message: "[ConstraintException] This property cannot be set to a null value." It will be wrong with a variabel called 'localpath' (mapped to a MDF database table). This value can have the value of NULL. So the message is understanding.

But my question is, what is the best way to handle this so the cell will be filled with a empty string.

Here some code:

        // Binding source
        _bs = new BindingSource();
        DatagridviewDirectories.DataSource = _bs;

        // _dc is the DataContext. Table is 'categories'
        _dc = new AudioSyncData();
        _bs.DataSource = _dc.categories;  // <-- here is the error

The error is happen in de EntityObject of categories:

public string localpath
{
  //...
  set
  {
       this._localpath = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
  }

}

So, who can help me with to understand this? Whats happen and how can i resolved this?

Thanks.