I have a drop down and the problem is that when i use html helpers for dropdown it is not getting the DataText field but the Id of selected item which i am displaying on another page. Please take a look.
<pre> @*<select name="DropDown" id="DropDown" class="ddl">
<option id="0">---Select----</option>
<option id="1">100</option>
<option id="2">200</option>
<option id="3">300</option>
<option id="4">400</option>
<option id="5">500</option>
<option id="6">800</option>
<option id="7">1000</option>
<option id="8">1200</option>
<option id="9">1500</option>
<option id="10">1800</option>
<option id="11">2000</option>
<option id="12">3000</option>
</select>*
@Html.DropDownList("DropDown", new List<SelectListItem> {
new SelectListItem {Text = "100", Value="1"},
new SelectListItem {Text = "200", Value="2"},
new SelectListItem {Text = "300", Value="3"},
new SelectListItem {Text = "400", Value="4"},
new SelectListItem {Text = "500", Value="5"},
new SelectListItem {Text = "800", Value="6"},
new SelectListItem {Text = "1000", Value="7"},
new SelectListItem {Text = "1200", Value="8"},
new SelectListItem {Text = "1500", Value="9"},
new SelectListItem {Text = "1800", Value="10"},
new SelectListItem {Text = "2000", Value="11"},
new SelectListItem {Text = "3000", Value="11"},
}, "Select", new { @class = "ddl" , id="DropDown"})
when i checked the O/P they both are producing the same HTML but Html is getting Text of selected field while html helper is getting the Id.
I am accessing the Text in "Show action method" like this
ViewBag.DistanceOfSubstation = model.DropDown;
P.S. i could use the simple Html but the validations do not work with it.