asp dropdownlist - add numbers 1-15 to list

前端 未结 5 850
日久生厌
日久生厌 2021-01-14 13:00

Is there a way of adding the values 1-15 to an asp dropdownlist without having to do each one individually...

I currently have:

ddlAdults.Items.Inser         


        
5条回答
  •  情话喂你
    2021-01-14 13:34

    for(int i=0;i<15;i++)
    {
       ddlAdults.Items.Insert(i, new ListItem((i+1).toString(), (i+1).toString()));
    }
    

提交回复
热议问题