Populating DropDownList inside Repeater not working

前端 未结 6 1561
长情又很酷
长情又很酷 2020-12-11 08:20

I\'m trying to populate a dropdown list inside a repeater, but I\'m not being very successful. I\'m probably using the wrong EventArgs e.

Here\'s my

6条回答
  •  误落风尘
    2020-12-11 09:04

    In the .aspx Page:

    
    

    In the Code-Behind:

    protected void criteriaScore_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    
        // This event is raised for the header, the footer, separators, and items.
    
        // Execute the following logic for Items and Alternating Items.
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==   
            ListItemType.AlternatingItem) 
        {
             DropDownList ddl = (DropDownList)e.Item.FindControl("ddlRating");
    
             for(int i=0; i < 5; i++)
             {
                ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
             }
        }
     }  
    

提交回复
热议问题