开发者

dropdownlist issue

开发者 https://www.devze.com 2023-01-13 13:00 出处:网络
I have a dropdownlist generated from db. Here is the result from page source. <select id=\"testList\" name=\"testList\">

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消