how to show the list of years?

Posted by Tejamanimala under ASP.NET on 10/17/2013 | Points: 10 | Views : 681 | Status : [Member] | Replies : 2
hi i want to show the year dropdown list which can maintain the so many years,like 1964 to 2222,without entering default in the dropdown items collection,is there any other control,please tell me

manimala


Responses

Posted by: Nismeh on: 10/18/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

You can add values dynamically using for loop. So that you can do it in very low amount of code line.
Try this lines under PageLoad

//DropDownList ddl
for (int i = 1964; i <= 2222; i++)
{
ddl.Add(i);
}
Or you can use

for (int i = 1964; i <= 2222; i++)
{
dd1.Add(new ListItem(i,"Value1 "+i); // Where Value is an propery of List
}



IT KNOWLEDGE IS APPLIED KNOWLEDGE
So Just Do It

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 10/18/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link
http://www.daniweb.com/web-development/aspnet/threads/282512/how-to-auto-update-years-in-dropdown-list

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Tejamanimala, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response