Drop Down List code

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
LVL 16
MikeMCSDAsked:
Who is Participating?
 
RejojohnyConnect With a Mentor Commented:
Sorry,
ddlDOBY.Items.Insert(0, new listitem("0", "Select Year"));
must be
ddlDOBY.Items.Insert(0, new ListItem("Select Year", "0"));
0
 
RejojohnyCommented:
Where are you dynmically populating the dropdown? just below that code
i.e below ddlDOBY.DataBind();

write
ddlDOBY.Items.Insert(0, new listitem("0", "Select Year"));
0
 
MikeMCSDAuthor Commented:
that did the trick, thanks Rejo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.