Login  Register 
Home
 
Applications
 
Consulting
 
Design
 
Business Links
 
Support
 
Contact
  Search
Search
 
 SupportKnowledge BaseC Sharp - C#     May 17, 2012  
Snippets
01

Populate a credit card expiration month DropDownList
for (int i = 1; i <= 12; i++)
{
    DateTime month = new DateTime(2011, i, 1);
    ListItem li = new ListItem(month.ToString("MMM (MM)"), month.ToString("MM"));
    ddlExpirationDateMonth.Items.Add(li);
}
ddlExpirationDateMonth.Items[0].Selected = true;

//Populate the credit card expiration year DropDownList (go out 7 years) 
for (int i = 0; i <= 6; i++)
{
    String year = (DateTime.Today.Year + i).ToString();
    ListItem li = new ListItem(year, year);
    ddlExpirationDateYear.Items.Add(li);
}
ddlExpirationDateYear.Items[0].Selected = true;

Posted in: C Sharp - C#

Post Rating

Comments

There are currently no comments, be the first to post one.

Post Comment

Only registered users may post comments.
 

P.O. BOX 2342 ~ BREWSTER, MA 02631
PHONE & FAX: (508) 714-0678

 
 Copyright 2012 by Global Internet Business Solutions   Terms Of Use  Privacy Statement