| |

VerySource

 Forgot password?
 Register
Search
View: 642|Reply: 3

To add multiple options for a dripdownlist in html? ? ? Waiting online

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-1-19 22:00:02
| Show all posts |Read mode
<asp: DropDownList ID = "DropDownList4" runat = "server">
<% for (int i = 1930; i <2005; i ++)
{
    <asp: ListItem value = "i"> i </ asp: ListItem>
}%>
</ asp: DropDownList>
year
Can you help me see what's wrong?
Reply

Use magic Report

0

Threads

21

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-1-27 21:36:01
| Show all posts
Write in server-side page_load event

if (! IsPostBack)
{

for (int i = 1930; i <2005; i ++)
DropDownList4.Items.Add (i.ToString ());
}
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

 Author| Post time: 2020-1-28 13:00:01
| Show all posts
Why cycle twice
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

 Author| Post time: 2020-1-28 22:00:02
| Show all posts
thank you! Succeeded!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list