N
NorCan
Hi
I'm creating an ASP.NET UserControl that contains a DropDownList
control. I'd like to be able to set the DataSourceID property of this
DropDownList through a UserControl property that at design time gives me
a list with the ID's of all DataSourceControl controls on the web page
containing the UserControl.
So let's say I have a web page with 4 ObjectDataSource controls, and I
add this new UserControl to the page (at design time, using VS 2005).
Selecting the UserControl and opening the Properties window I want a
property 'ProductTypeDataSourceID' that lets me choose one of the 4
ObjectDataSource controls from a dropdown list, as if the UserControl
was a DropDownList or some other DataBoundControl (I don't need the <new
data source...> option, just the list).
I've been able to create the property, but just as a plain string
property (no dropdown).
This is the code I have at the moment:
[IDReferenceProperty(typeof(DataSourceControl))]
[TypeConverter(typeof(DataSourceIDConverter))]
[Category("Data")]
[Description("The Control ID of an IDataSource that will be used as the
data source")]
[Browsable(true)]
public string ProductTypeDataSourceID
{
get { return ddlProductType.DataSourceID; }
set { ddlProductType.DataSourceID = value; }
}
I've tried different attribute combinations, including the Editor and
EditorBrowsable attributes, as well as just using a getter or a setter,
and a host of other suggestions I've found online, but nothing helps.
What am I doing wrong?
Regards,
Frode
I'm creating an ASP.NET UserControl that contains a DropDownList
control. I'd like to be able to set the DataSourceID property of this
DropDownList through a UserControl property that at design time gives me
a list with the ID's of all DataSourceControl controls on the web page
containing the UserControl.
So let's say I have a web page with 4 ObjectDataSource controls, and I
add this new UserControl to the page (at design time, using VS 2005).
Selecting the UserControl and opening the Properties window I want a
property 'ProductTypeDataSourceID' that lets me choose one of the 4
ObjectDataSource controls from a dropdown list, as if the UserControl
was a DropDownList or some other DataBoundControl (I don't need the <new
data source...> option, just the list).
I've been able to create the property, but just as a plain string
property (no dropdown).
This is the code I have at the moment:
[IDReferenceProperty(typeof(DataSourceControl))]
[TypeConverter(typeof(DataSourceIDConverter))]
[Category("Data")]
[Description("The Control ID of an IDataSource that will be used as the
data source")]
[Browsable(true)]
public string ProductTypeDataSourceID
{
get { return ddlProductType.DataSourceID; }
set { ddlProductType.DataSourceID = value; }
}
I've tried different attribute combinations, including the Editor and
EditorBrowsable attributes, as well as just using a getter or a setter,
and a host of other suggestions I've found online, but nothing helps.
What am I doing wrong?
Regards,
Frode