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 / General / April 2008

Tip: Looking for answers? Try searching our database.

What is the best practice for DropDownList with static items?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bogdan - 07 Apr 2008 17:17 GMT
Hi,

I'd like to use a dropdownlist in a formview to map numeric values to
'user-friendly' descriptions.  The dropdownlist items' values need to be
bound to a column in a db table.  For example, users might see "Type1",
"Type2", and "Type3" but corresponding values stored in db are 1, 2, and 3.
Seems like a very common scenario.  Could anyone please let me know what the
best practice is in this case?  Should I create a custom data source or
simply bind an array to the dropdownlist in Page_Load()?  I remember seeing
a sample that I liked (might've been one of Scott Mitchell's tutorials) some
time ago but can't find it now.

I'm quite comfortable with binding db data sources to controls.

Thanks,
Bogdan
David Wier - 07 Apr 2008 17:44 GMT
the very simplest of solutions would be to create a simple stored procedure,
retrieving the items, putting the 1, 2 & 3 items as the DataValueField item
of the Dropdownlist, and the Type2 items as the DataTextField (visible)

You could either create a Dataset (xsd), and ObjectDataSource for this, or
simply create a SQLDataSource for it

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup

> Hi,
>
[quoted text clipped - 12 lines]
> Thanks,
> Bogdan

Rate this thread:







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



©2008 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.