Solved

Dropdown list creating values from current year

Posted on 2011-03-09
2
356 Views
Last Modified: 2012-05-11
I am using dot net and I want to create a dropdown list that contains the current year and the next ten years. I am not sure how to populate the table.  

Something like below which does not work.

    <asp:DropDownList ID="DropDownList1" runat="server">
                <asp:ListItem Value="=year(getdate())"></asp:ListItem>
                 <asp:ListItem Value="=year(getdate() + 1)"></asp:ListItem>
            </asp:DropDownList>
     

0
Comment
Question by:kw66722
2 Comments
 
LVL 4

Accepted Solution

by:
Tuyau2poil earned 500 total points
ID: 35088731
populate your DDL with codebehind :

 Dim intYear As Integer
    Dim intStart As Integer = DateTime.Now.Year
    Dim intEnd As Integer = DateTime.Now.Year + 10
 
    For intYear = intStart To intEnd
        DropDownList1.Items.Add(intYear.ToString())
    Next
0
 
LVL 1

Author Comment

by:kw66722
ID: 35089907
that worked.  I created a control and up the code in the init event.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now