Solved

Enumeration for months?

Posted on 2006-07-20
4
230 Views
Last Modified: 2010-04-16
Hi all, I'm trying to convert a string value selected from a drop down control to a numeric value and having trouble.  List of values are the months, spelled out (January, February,...).  When the user selects one of these, I want to be able to convert this TimeFrame.SelectedValue to an int, January = 1, Feb =2....   integer variable is monthstart.

I don't have much (ok, any) experience with enumerations, but from what I do understand about the language, this is probably way to go.  How can I make the conversion??

Any help would be appreciated,

Thanks in advanced

0
Comment
Question by:aaalife
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
osmantemiz earned 500 total points
ID: 17148033
first of all you dont have to use enumaration for that kind of thing just do that

TimeFrame.Items.Clear();
TimeFrame.Items.Add("Select Month");
TimeFrame.Items.Add("January");
TimeFrame.Items.Add("February);
.
.
.
.
.// just add like this
.
.
TimeFrame.Items.Add("December");

Now if you get the TimeFrame.SelectedValue it will return your int :)
0
 
LVL 3

Expert Comment

by:osmantemiz
ID: 17148038
sorry... Not SelectedValue you should get SelectedIndex ...
0
 

Author Comment

by:aaalife
ID: 17148116
i need January to =1, will TimeFrame.SelectedIndex start at 0, so i have to + 1, or does the index start with 1??
0
 

Author Comment

by:aaalife
ID: 17148122
never mind, re-read your answer, got it.

thanks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get id from json Data with NewtonSoft 3 49
Angular - break the dataset in chunks? 7 50
converto datetime always changes format 9 35
FTP file download using c# 3 21
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now