I am entering in Floor numbers to a DropDownList within a DetailsView Template Field. The floor count is variable and is entered from a prior DDL depending on the amount of floors in a chosen building. Once the amount of floors is passed, it should iterate through numbers until the floor number is reached. In this instance, there are 15 floors. I am doing it like this:
int i;
int cnt = Convert.ToInt32(tmpBox3.SelectedItem.Text); //15
for (i = 0; i <= cnt; i++)
{
tmpBox3.Items.Insert(i, new ListItem(i.ToString(), i.ToString()));
}
tmpBox3.Items.Remove(new ListItem("0")); //remove zero
tmpBox3.Items.Remove(new ListItem(cnt.ToString())); //remove duplicate 15
tmpBox3.Items.Insert(0, new ListItem("--Select--","0")); //add select
tmpBox3.SelectedIndex = 0; // make select default choice
Here's the output and the problem. Sorry for the goofy tags
[option selected="selected" value="0"]--Select--[/option]
[option value="1"]1[/option]
[option value="2"]2[/option]...
[option value="14"]14[/option]
[option value="1"]15[/option]
The last entry value is the issue. I can't seem to make that 15. Any tips are most welcome.