IDI am using the following code to create a drop down list:
@for (var index = 0; index < Model.AdminSummaries.Count(); index++)
{
&
Sometimes the HTML helpers don't HELP. DropDownListFor coding can get complicated real fast and in the end it's just rendering HTML so sometimes it's better to go old school
<select name="myname" class="dropdownlist" id="myid">
@foreach (SelectListItem item in Model.SomeSelectList) {
if (item.Value == Model.theValue) {
<option value="@(item.Value)" selected="selected">@item.Text</option>
} else {
<option value="@(item.Value)">@item.Text</option>
}
}
</select>
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 ) });
Thanks .. it work...adding .Name change the name of the html password attribute
@Html.PasswordFor(Function(model) model.password, New With {.Autocomplete = "off", .Name = "oldpassword", .id = "oldpassword", .value = Model.password, .readonly = True})