dropdown list

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>
 
D

darrel

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
 
H

hashimisayed

B

Britney

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.
 
B

Britney

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.
 
D

darrel

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top