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

前端 未结 9 1624
爱一瞬间的悲伤
爱一瞬间的悲伤 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:40

    ID can be changed as described by @Arbiter. However, if you want to change the name, then I think you need to use @Html.DropDownList rather than @Html.DropDownListFor. This loses you any benefits of having the strong typing for the property element, but as just changing IDs means you can't access the values in a meaningful way if looking at the Request.Form response, this may be an acceptable workaround for you.

提交回复
热议问题