Html Code conversion [Resolved]

Posted by Rasagna under ASP.NET MVC on 3/4/2016 | Points: 10 | Views : 1651 | Status : [Member] | Replies : 3
Hii,
What might be the possible @Html.DropdownList code for the below Html code.

 <select class="dropdown-list form-control"  data-val="true"  data-val-required="The GroupId field is required."  id="groupsListId"  name="GroupId"><option value="-1">Select Group</option> </select>





Responses

Posted by: Rajnilari2015 on: 3/5/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this

@Html.DropDownListFor(model => model.GroupId, new SelectList(
new List<Object>{
new { value = -1 , text = "Select Group" }
},
"value",
"text",
2),new { @class = "dropdown-list form-control" })
@Html.ValidationMessageFor(model => model.GroupId)


Hope that helps

--
Thanks & Regards,
RNA Team

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rasagna on: 3/7/2016 [Member] Starter | Points: 25

Up
0
Down
Thanks helped

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajnilari2015 on: 3/7/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 25

Up
0
Down
@Rasagna, glad to know that (:

--
Thanks & Regards,
RNA Team

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response