kwilliams Posted April 6, 2010 Report Share Posted April 6, 2010 I need to populate a dropdownlist with a set of numbers that are looped (0 - 10). The code I have below works as a static option:Dim numbers() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}...but I'd like to have a loop working something like thisDim n As Integer = 0For n = 0 To 10Response.Write(n)Next nDoes anyone know how to do this? Thanks. Link to comment Share on other sites More sharing options...
kwilliams Posted April 6, 2010 Author Report Share Posted April 6, 2010 Here's the solution:Dim n As IntegerFor n = 0 To 10 Dim listItem As New ListItem listItem.Text = n DropDownList1.Items.Add(listItem)NextThanks anyway:) Link to comment Share on other sites More sharing options...
sukhdev_ce Posted August 10, 2010 Report Share Posted August 10, 2010 Dim n As IntegerFor n = 0 To 10 DropDownList1.Items.Add(n.ToString())Nextits a simple solution of your problem. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now