MVC: How do i declare the name value using DropDownListFor

Posted by frosty on Stack Overflow See other posts from Stack Overflow or by frosty
Published on 2010-05-16T18:24:56Z Indexed on 2010/05/16 18:30 UTC
Read the original article Hit count: 301

Filed under:

I have the following dropdownlist in mvc

 <%= Html.DropDownListFor(c => c.Address.Id, new SelectList(Model.Addresses, "id", "Name", Model.Address.Id), "-- New Address --", new { @name = "[" + orderItemAddressCount + "].AddressId" })%>

I'm trying to overwrite the name value on the dropdownlist.

this is the markup i get

 <select id="Address_Id" name="Address.Id"><option value="">-- New Address --</option>

This is the markup i want

-- New Address --

How do i declare the name value using DropDownListFor?

© Stack Overflow or respective owner

Related posts about asp.net-mvc