Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Html.DropDownList selected value from a list<string>
- List<string> x = new List<string> { "string1", "string2", "string3", " string4" };
- ViewBag.Relacion = new SelectList(x);
- <div class="editor-label">
- @Html.LabelFor(model => model.Relacion)
- </div>
- <div class="editor-field">
- @Html.DropDownList("Relacion")
- @Html.ValidationMessageFor(model => model.Relacion)
- </div>
- <script type="text/javascript">
- $(document).ready(function () {
- $('select[name=Relacion]').val($('#Relaciontext').val());
- }
- </script>
- <div class="editor-field" style="display:none" >
- @Html.TextBox("Relaciontext", ViewData["statecode"])
- </div>
- @Html.DropDownList("Relacion")
- ViewData["statecode"]="string1";
- @Html.DropDownListFor(model => model.Relacion, (IEnumerable<SelectListItem>)ViewData["Relacion"])
Advertisement
Add Comment
Please, Sign In to add comment