O
Oliver Petry
I'm developing an WebControl in ASP.NET 2.0. The control inherits from
DataBoundControl, so it can be bound to a DataSourceControl by it's
DataSourceID property. When I declare a property with the attribute
[TypeConverter(typeof(DataFieldConverter))] a drop down list of all fields
(respectively columns) of the data source is shown in the designer. So far,
so good. But this doesn't work inside a sub property.
Here is my code. The DataContextControl contains a list of
DataFieldPropertyCollection called Field. The DataFieldProperty has a
property called DataPropertyName. What is necessary, to provide the drop down
list of DataSourceControls on the page for the DataSourceID Property und a
drop down list of fields (i.e columns) of the selected DataSource?
[DefaultProperty("DataSourceID")]
[ParseChildren(true, "Fields")]
[ToolboxData("<{0}ataContextControl
runat=server></{0}ataContextControl>")]
public class DataContextControl : DataBoundControl
{
private DataFilterFieldPropertyCollection fields;
public DataFilterContextControl()
{
this.fields = new DataFilterFieldPropertyCollection(this);
}
[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(DataFilterContextControl.DataFilterFieldPropertyCollectionEditor),
typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public DataFilterFieldPropertyCollection Fields
{
get { return fields; }
}
....
}
public class DataFieldProperty
{
private string dataPropertyName;
[Category("Data")]
[DefaultValue("")]
[Localizable(false)]
[IDReferenceProperty(typeof(DataSourceControl))]
[TypeConverter(typeof(DataSourceIDConverter))]
public string DataSourceID
{
get { return dataSourceID; }
set { dataSourceID = value; }
}
[NotifyParentProperty(true)]
[TypeConverter(typeof(DataFieldConverter))]
public string DataPropertyName
{
get { return dataPropertyName; }
set { dataPropertyName = value; }
}
....
}
Thank you,
Oliver
DataBoundControl, so it can be bound to a DataSourceControl by it's
DataSourceID property. When I declare a property with the attribute
[TypeConverter(typeof(DataFieldConverter))] a drop down list of all fields
(respectively columns) of the data source is shown in the designer. So far,
so good. But this doesn't work inside a sub property.
Here is my code. The DataContextControl contains a list of
DataFieldPropertyCollection called Field. The DataFieldProperty has a
property called DataPropertyName. What is necessary, to provide the drop down
list of DataSourceControls on the page for the DataSourceID Property und a
drop down list of fields (i.e columns) of the selected DataSource?
[DefaultProperty("DataSourceID")]
[ParseChildren(true, "Fields")]
[ToolboxData("<{0}ataContextControl
runat=server></{0}ataContextControl>")]
public class DataContextControl : DataBoundControl
{
private DataFilterFieldPropertyCollection fields;
public DataFilterContextControl()
{
this.fields = new DataFilterFieldPropertyCollection(this);
}
[Category("Data")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Editor(typeof(DataFilterContextControl.DataFilterFieldPropertyCollectionEditor),
typeof(UITypeEditor)), PersistenceMode(PersistenceMode.InnerDefaultProperty)]
public DataFilterFieldPropertyCollection Fields
{
get { return fields; }
}
....
}
public class DataFieldProperty
{
private string dataPropertyName;
[Category("Data")]
[DefaultValue("")]
[Localizable(false)]
[IDReferenceProperty(typeof(DataSourceControl))]
[TypeConverter(typeof(DataSourceIDConverter))]
public string DataSourceID
{
get { return dataSourceID; }
set { dataSourceID = value; }
}
[NotifyParentProperty(true)]
[TypeConverter(typeof(DataFieldConverter))]
public string DataPropertyName
{
get { return dataPropertyName; }
set { dataPropertyName = value; }
}
....
}
Thank you,
Oliver