Click here to Skip to main content
15,906,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to bind 100 number into dropdownlist
Posted

You should use this.

C#
for (int i = 1; i <= 100 ; i++) {
    ListItem item = new ListItem(i);
    dropdownlist.Items.Add(item);
}
 
Share this answer
 
Very basic question.
dropdownlist has method to add items in it.

C#
Dropdownlist.Items.Add("value you want to add")

u can use looping to add values in dropdownlist
 
Share this answer
 
v2
try this:

C#
ddl.Items.Clear();
            ddl.Items.Add(string.Empty);
            for (int i = 0; i <= 100; i++)
            {
                ddl.Items.Add(i.ToString());
            }
 
Share this answer
 
you will have to add code in code behind. you need not add huge amount of stuff in designing part.

just add following code :

C#
             for (int i = 0; i <= 100; i++)
{
      ddl.Items.Add(i);
}



you can also go with any of first 2 solutions.

-Sagar Solanki
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900