Welcome to Jordev Sign in | Join | Help
 
in Search

fills a dropDownlist with month Names

Last post 07-13-2007, 4:56 AM by Zero. 0 replies.
Sort Posts: Previous Next
  •  07-13-2007, 4:56 AM 1150

    fills a dropDownlist with month Names

    i know i can do it i 10000000000 ways but why not ad one to them !!!!  

    Small Simple And Dynamic ,finaly Localized in any language that .net support

    try it and tell me  

     #region Method to Fill the a DropDownList with Month Names and set the Current Month Selected
            /// <summary>
            /// fills a dropDownlist with month list.
            /// </summary>
            /// <PARAM name="MyddlMonthList" />The DropDown List that will Hold the Months.</PARAM />
            /// <PARAM name="SetCurruntMonth" />if set to <c>true</c> the Current Month will be selected.</PARAM />
            public void GetMyMonthList(DropDownList MyddlMonthList,bool SetCurruntMonth)
            {
                DateTime month = Convert.ToDateTime("1/1/2000");
                for (int i = 0; i < 12; i++)
                {

                    DateTime NextMont = month.AddMonths(i);
                    ListItem list = new ListItem();
                    list.Text = NextMont.ToString("MMMM");
                    list.Value = NextMont.Month.ToString();
                    MyddlMonthList.Items.Add(list);
                }
                if (SetCurruntMonth == true)
                {
                    MyddlMonthList.Items.FindByValue(DateTime.Now.Month.ToString()).Selected = true;
                }         

            }
            #endregion

    PS same code i added in codeproject


    ZeroDev
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems