dropdown list

  • Thread starter Thread starter Britney
  • Start date Start date
B

Britney

hi I want to create an age drop-down list.
values for age is from 1 to 100. It seems so easy but I have to write over
100 lines of codes (100 listitems)
Is there a simple way to achieve the same solution as below?




<asp:DropDownList id="DdAgeStart" runat="server">
<asp:ListItem Value="1" Text="1"></asp:ListItem>
<asp:ListItem Value="2" Text="2"></asp:ListItem>
...........
</asp:DropDownList>
 
Is there a simple way to achieve the same solution as below?

Use codebehind

<asp:DropDownList id="DdAgeStart" runat="server">

dim intAge as integer = 1

While intAge < 101
DdAgeStart.Items.Insert(New ListItem(intAge, intAge ))
intAge = intAge + 1
end while

Though, a 100-item select list is a bit of a pain to use. A text box might
make a lot more sense here.

-Darrel
 
what do you mean use codebehind?
I don't think <asp:DropDownList id="DdAgeStart" runat="server"> will work
in codebehind.
that's on my aspx page.
 
no... It must be dropdown list.
because I just want to learn how to use it.... =)
 
never mind.. I got it.. thanks

Britney said:
what do you mean use codebehind?
I don't think <asp:DropDownList id="DdAgeStart" runat="server"> will work
in codebehind.
that's on my aspx page.
 
never mind.. I got it.. thanks

You're welcome. Sorry about not clarifying the codebehind part.

-Darrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top