UserControl property as dropdown at design time?

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
 
A

Alessandro Zifiglio

hi Frode, then you want to write a custom web control and not use a
usercontrol. Usercontrols are limited in designtime features and is one of
the main difference btw UserControls and WebControls.

Regards,
Alessandro Zifiglio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top