« Home | Visual Studio Automatically Changing the IDs in So... » | Better Perfomance of Web Applications » | Display Numerals in Arabic Format » | The Controls collection cannot be modified because... » | Team Foundation PowerToys » | String is All Lower or All Upper Case » | Detecting Chrome browser in ASP.NET » | Chart Control for .net 3.5 » | Increase the VS screen for HTML pages » | Working with Dynamic Controls »

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...

Labels: , , , , , ,

Post a Comment