views:

24

answers:

1

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 why 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");
+4  A: 

Because I suppose that you have used a value type such as Int32 for the Id property. Try using a nullable integer instead: int?

Darin Dimitrov
@ Darin Dimitrov -- thanks, by changing int to int? solved it.
hersh