asp dropdownlist - add numbers 1-15 to list

前端 未结 5 905
日久生厌
日久生厌 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:31

    //cmbDay.Items.Insert(0, new ListItem("1"));
    //cmbDay.Items.Insert(1, new ListItem("2"));
    //cmbDay.Items.Insert(2, new ListItem("3"));
    //cmbDay.Items.Insert(3, new ListItem("4"));
    
    for( i=0;i<15;i++)
        {
           cmbDay.Items.Insert(i,new ListItem(i.ToString()));
        } 
    

提交回复
热议问题