Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

days in month

This topic is 2252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to extract a value from a dropdownlist.I am usiing dropdownlists to store the date of birth for an application.I have the years and months to output correct.I have am having a problem in getting the days of the month to sync with the number of days in a month.here is the code I am using .

int month = Convert.ToInt32(DropDownList1.SelectedValue);

Share this post


Link to post
Share on other sites
Advertisement
Are you using the names of the months? If so, ToInt32 won't work. ToInt32 only expects numbers-as-text. It wouldn't know what to do with the name of a month, or anything else for that matter.

You may try: http://stackoverflow.com/questions/258793/how-to-parse-a-month-name-string-to-an-integer-for-comparison-in-c

Alternatively, you can just use DropDownList1.SelectedIndex (and add 1 if you need to). Edited by Nypyren

Share this post


Link to post
Share on other sites
Did you try DateTime.DaysInMonth method? You can make 2 dropdown list, one to select the month and when that is selected, it populates the other dropdown list with the appropriate number of days. If you use this method, you can use both numerical and string representations for months. Edited by NDraskovic

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!