I have a dropdownlist generated from db. Here is the result from page source.
<select id="testList" name="testList">
<option value="0"></option>
<option value="0">A</option>
<option value="1">B</option>
</select>
Does anyone know 开发者_如何学Gowhy the empty is still zero? How come I dont get something like "" for the first one since it's empty?
<div class="editor-field">
<%= Html.DropDownList("list") %>
</div>
ViewData["list"] = new SelectList(list, "Id", "Value");
Because I suppose that you have used a value type such as Int32 for the Id
property. Try using a nullable integer instead: int?
精彩评论