Can I change the html name generated by Html.DropDownListFor?

前端 未结 9 1756
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 03:04

IDI am using the following code to create a drop down list:

 @for (var index = 0; index < Model.AdminSummaries.Count(); index++) 
            { 
            &         


        
9条回答
  •  忘了有多久
    2021-02-05 03:47

    You can set/change the ID just like any HTML attribute (but not name I've found).

    @Html.DropDownListFor(x => Model.AdminSummaries[index].Status, AdminStatusReference.GetAdminStatusOptions(), new { id = string.Format("Status_{0}",index ) });
    

提交回复
热议问题