Credit Card Expiration Date DropDownList Sample Code
Below is the sample code for populating Credit Cart Expiration Date DropDownList.
//Populate the credit card expiration month drop down
for (int i = 1; i <= 12; i++) { DateTime month = new DateTime(2000, i, 1); ListItem li = new ListItem(month.ToString("MMM (M)"), month.ToString("MM")); ExpirationDateMonthDropDown.Items.Add(li); } //Populate the credit card expiration year drop down (go out 12 years) for (int i = 0; i <= 11; i++) { String year = (DateTime.Today.Year + i).ToString(); ListItem li = new ListItem(year, year); ExpirationDateYearDropDown.Items.Add(li); }
Happy Coding...
//Populate the credit card expiration month drop down
for (int i = 1; i <= 12; i++) { DateTime month = new DateTime(2000, i, 1); ListItem li = new ListItem(month.ToString("MMM (M)"), month.ToString("MM")); ExpirationDateMonthDropDown.Items.Add(li); } //Populate the credit card expiration year drop down (go out 12 years) for (int i = 0; i <= 11; i++) { String year = (DateTime.Today.Year + i).ToString(); ListItem li = new ListItem(year, year); ExpirationDateYearDropDown.Items.Add(li); }
Happy Coding...
Labels: .net2.0, .net3.5, credit card, dropdownlist, expiration, microsoft, visual studio
Post a Comment