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 / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

Using a Class enumeration as a Data Source

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dwok - 23 May 2005 16:34 GMT
Hello,

 I have a class that contains an enumeration and I would like to bind
the members of the enumerations to a drop down list box. If have seen
some examples that use Enum.GetNames and Enum.GetValues but when ever I
pass the name of my enumeration I get an error. Let me illustrate.

--- VB.NET Code ----------

Public Class Phone

   Public Enum PhoneNumberType
     Home = 1
     Work = 2
     Mobile = 3
     Fax = 4
     Pager = 5
   End Enum

End Class

--- ASP.NET Code -------

dropDownListBox.DataSource =
System.Enum.GetValues(Phone.PhoneNumberType)

It's here that I get an error. "PhoneNumberType is a type in Phone and
cannot be used as an expression". Any guess on what I might be doing
wrong? Thanks.

-dwok
DotNetWorks - 23 May 2005 20:38 GMT
Hi,
Try this..
Dim t1 As Type = GetType(Phone.PhoneNumberType)
dropDownListBox.DataSource = System.Enum.GetValues(t1)
dropDownListBox.DataBind();

> Hello,
>
[quoted text clipped - 27 lines]
>
> -dwok

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.