mvc radiobuttons in foreach

后端 未结 3 968
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 13:31

I\'m using MVC and I have some RadioButtons in a foreach:

    foreach (var item in group) {
                    
                                 


        
3条回答
  •  醉话见心
    2020-12-14 13:55

    One way is to use a for loop and RadioButton instead of RadioButtonFor

    @for (int i = 0; i < item.Count; i++)
    {
        
            
                @Html.RadioButton("item_CheckerApproved_" + i, true, item[i].CheckerApproved)
                @Html.RadioButton("item_CheckerApproved_" + i, false, !item[i].CheckerApproved)
            
        
    }
    

提交回复
热议问题