Click here to Skip to main content
11,929,232 members (49,751 online)
Click here to Skip to main content
Add your own
alternative version


18 bookmarked

Dynamic DropDownList with Month Names

, 13 Jul 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Method to Fill the a DropDownList with Month Names and set the Current Month Selected
how to Creat a DropDownList with Month Names
#region Method to Fill the a DropDownList with Month Names and set the Current Month Selected
        /// <span class="code-SummaryComment"><summary>
thats it Happy Coding


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chief Technology Officer
Jordan Jordan
Life is really simple, but we insist on making it complicated

You may also be interested in...

Comments and Discussions

QuestionShort Code and simple Pin
The Zero31-Jan-15 9:43
memberThe Zero31-Jan-15 9:43 
GeneralMy vote of 4 Pin
Diwakar Gupta16-Dec-11 2:53
memberDiwakar Gupta16-Dec-11 2:53 
GeneralGood Job Pin
Prakash Varun 201014-Jul-10 20:33
memberPrakash Varun 201014-Jul-10 20:33 
GeneralOther option Pin
christianfdiazm27-Nov-09 7:24
memberchristianfdiazm27-Nov-09 7:24 
GeneralHere is a VB Version Pin
Mr. Hef2-Oct-07 6:35
memberMr. Hef2-Oct-07 6:35 
GeneralRe: Here is a VB Version Pin
ZeroDev3-Oct-07 8:08
memberZeroDev3-Oct-07 8:08 
GeneralSome changes in your code Pin
Eduardo Calixto13-Jul-07 4:24
memberEduardo Calixto13-Jul-07 4:24 
Hello ZeroDev,

I did some changes in your function. Now you can set any culture that you want or use the same culture that the resource manager (probably the last option is the better but i did it complete to ilustrate how you can change the culture)

public void GetMyMonthList(DropDownList MyddlMonthList,bool SetCurruntMonth, string strCulture)
   System.Globalization.DateTimeFormatInfo dti;

   if ( String.IsNullOrEmpty( strCulture) )
      // Get cultureinfo culture used by the resource manager
      dti = System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat;
      // Create a cultureinfo using the especified culture parameter
      dti = new System.Globalization.CultureInfo(strCulture, false).DateTimeFormat;
   for (int i = 1; i < 13; i++)
      ListItem list = new ListItem(dti.GetMonthName(i), i.ToString() );
   if (SetCurruntMonth == true)
      MyddlMonthList.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;

GeneralRe: Some changes in your code Pin
ZeroDev13-Jul-07 4:30
memberZeroDev13-Jul-07 4:30 
GeneralThanks Pin
ZeroDev13-Mar-07 22:37
memberZeroDev13-Mar-07 22:37 
GeneralExactly what I wanted Pin
toxaq13-Mar-07 11:06
membertoxaq13-Mar-07 11:06 
GeneralGood Job!!! Pin
Domingo M. Asuncion6-Mar-07 16:31
memberDomingo M. Asuncion6-Mar-07 16:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 13 Jul 2007
Article Copyright 2006 by ZeroDev
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid