all groups > dotnet windows forms databinding > september 2007 >
You're in the

dotnet windows forms databinding

group:

DataTable as a bindable property type


DataTable as a bindable property type Dmitry Nogin
9/27/2007 11:21:56 AM
dotnet windows forms databinding: Hi,

Could you please suggest me something?

This code works witout exceptions:
public partial class Form1 : Form
{
private object _source =3D null;
public object Source
{
get { return _source; }
set { _source =3D value; }
}
private object _target;
public object Target
{
get { return _target; }
set { _target =3D value; }
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DataBindings.Add("Target", this, "Source");=20
}
}

This code raises an exception at OnLoad ("Cannot format the value to the =
desired type"):
public partial class Form1 : Form
{
private DataTable _source =3D null;
public DataTable Source
{
get { return _source; }
set { _source =3D value; }
}
private DataTable _target;
public DataTable Target
{
get { return _target; }
set { _target =3D value; }
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DataBindings.Add("Target", this, "Source");=20
}
}

The only defference here is the data type of properties.
I have to make it work properly with null values and DataTable types.
Do you have any ideas?

Thanks!

Re: DataTable as a bindable property type Dmitry Nogin
9/27/2007 12:06:02 PM
I encountered the same problem when data type is =
MarshalByValueComponent.

[quoted text, click to view]
Hi,

Could you please suggest me something?

This code works witout exceptions:
public partial class Form1 : Form
{
private object _source =3D null;
public object Source
{
get { return _source; }
set { _source =3D value; }
}
private object _target;
public object Target
{
get { return _target; }
set { _target =3D value; }
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DataBindings.Add("Target", this, "Source");=20
}
}

This code raises an exception at OnLoad ("Cannot format the value to =
the desired type"):
public partial class Form1 : Form
{
private DataTable _source =3D null;
public DataTable Source
{
get { return _source; }
set { _source =3D value; }
}
private DataTable _target;
public DataTable Target
{
get { return _target; }
set { _target =3D value; }
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
DataBindings.Add("Target", this, "Source");=20
}
}

The only defference here is the data type of properties.
I have to make it work properly with null values and DataTable types.
Do you have any ideas?

Thanks!

AddThis Social Bookmark Button