Drop Down List code

Posted on 2007-10-19
Last Modified: 2010-04-15
I'm populating a drop down list dynamically in code, but
I want to add this after:

   Text="Select Year"    Value="0"    Selected="True"

<asp:DropDownList ID="ddlDOBY" runat="server">

I can do it VB but I need it in C# . . which I'm still struggling to learn.  thanks
Question by:MikeMCSD
    LVL 26

    Expert Comment

    Where are you dynmically populating the dropdown? just below that code
    i.e below ddlDOBY.DataBind();

    ddlDOBY.Items.Insert(0, new listitem("0", "Select Year"));
    LVL 26

    Accepted Solution

    ddlDOBY.Items.Insert(0, new listitem("0", "Select Year"));
    must be
    ddlDOBY.Items.Insert(0, new ListItem("Select Year", "0"));
    LVL 16

    Author Comment

    that did the trick, thanks Rejo

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 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

    18 Experts available now in Live!

    Get 1:1 Help Now