Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / June 2006

Tip: Looking for answers? Try searching our database.

UserControl property as dropdown at design time?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NorCan - 09 Jun 2006 13:51 GMT
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
Alessandro Zifiglio - 13 Jun 2006 08:42 GMT
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
> Hi
>
[quoted text clipped - 37 lines]
> Regards,
> Frode

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.