SIGN UP MEMBER LOGIN:    
ARTICLE

Automatic Binding of Days, Months, Years to a DropDownList Control

Posted by Suthish Nair Articles | Visual C# September 22, 2010
This blog shows a simple snippet of binding days, months and years to a DropDownList.
Reader Level:
Download Files:
 



This blog shows a simple snippet of automatic binding of Days, Months, Years to a DropDownList/ListBox control.

Below following methods were used for the purpose.

For binding Days:
  1. System.DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).
  • Method returns Total Days in a Month.

  • Method returns the last day of the month.
4.jpg

For binding DayNames
  1. Doing a for-each loop to retrieve Day Names from DateTimeFormatInfo.CurrentInfo.DayNames.
2.jpg

For binding MonthNames
  1. Doing a for-each to retrieve Month Names from DateTimeFormatInfo.CurrentInfo.MonthNames.
3.jpg

Some styling is also applied; you can uncomment those code and test the samples attached.

The output will shown as below.

image2.gif


Please rate and post your comments !
 

Thank You!

 

Login to add your contents and source code to this article
share this article :
post comment
 

Thanks for sharing ..

Posted by srikanth kumar Dec 01, 2011

Thanx Madhu, you can post your threads to forum section..

Posted by Suthish Nair Aug 04, 2011

1.I want examples on dependency Proparties? can any body help me.

Posted by Madhu B Aug 04, 2011

Its Very Nice

Posted by Madhu B Aug 04, 2011

thanks a lot:)

Posted by surender bhyan Jun 03, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor