Hi, I'm trying to create browsable DataSource and DataMember
properties on a user control.
The idea is to create a descendent object, place a dataset then
specify the DataSource (DataSet) and DataMember (DataTable) by
browsing the controls properties.
I am close, but somtimes get an error when bad values get put into the
DataMember property.
Pretty sure I'm missing something. Can anybody help? Thanks!
Here's what I have so far:
/// <summary>
/// The DataSet used as the Master row set.
/// </summary>
[Browsable(true)]
[Category("Data")]
[Description("The DataSet used for this Child row set.")]
public System.Data.DataSet DataSource
{
get
{
return _DataSource;
}
set
{
_DataSource = value;
}
}
/// <summary>
/// The Table in the DataSet used for this Child row set.
/// </summary>
[Browsable(true)]
[Category("Data")]
[Description("The Table in the DataSet used for this Child row
set.")]
public System.Data.DataTable DataMember
{
get
{
return _DataMember;
}
set
{
_DataMember = value;
}
}
Nicholas Paldino [.NET/C# MVP] - 31 Jan 2008 18:27 GMT
Well, you shouldn't be typing the DataSource property as a DataSet and
the DataMember property as a DataTable, as databinding only requires that
the data source implement IList.
You should check the DataSource and DataMember properties on other
data-bound controls through Reflector, and take note of the attributes
applied to those. If you copy them, they will enable design-time support
for setting the data source and data member through the designer.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi, I'm trying to create browsable DataSource and DataMember
> properties on a user control.
[quoted text clipped - 45 lines]
> }
> }