Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

c# drop down box error

Posted on 2012-08-21
1
Medium Priority
?
729 Views
Last Modified: 2012-08-21
getting error on following code:
   ddlExpYear.Items.Add(i);


Error      54      The best overloaded method match for 'System.Web.UI.WebControls.ListItemCollection.Add(System.Web.UI.WebControls.ListItem)' has some invalid arguments      C:\Development\ELT\TitleTec.ELT.Web\SignUp\SignUp.aspx.cs      392      17      TitleTec.ELT.Web



 DateTime dt = DateTime.Now; ;
            //int currYear = Year(Now());
            int currYear = Convert.ToInt32(dt.Year.ToString());
           
            for (i = currYear; i <= currYear + 10; i++)
            {
                ddlExpYear.Items.Add(i);
            }
0
Comment
Question by:Meinhoonaa
1 Comment
 
LVL 18

Accepted Solution

by:
Rajar Ahmed earned 2000 total points
ID: 38317685
try this,
  DateTime dt = DateTime.Now; ;
        //int currYear = Year(Now());
        int currYear = Convert.ToInt32(dt.Year.ToString());

        for (int i = currYear; i <= currYear + 10; i++)
        {
            ddlExpYear.Items.Add(i.ToString());
        }

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

578 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