I have following code in my MVC2 view:
<tr class="edit" style="display:none">
<td>
<%= Html.DropDownList("drpFields", new SelectList(Model.Fields, "FieldID", "NiceName", whiteout.FieldID)) %>
</td>
<td>
<%= Html.DropDownList("drpStartTimeh", new SelectList(Model.Hours, whiteout.StartHour.Hour.ToString("0,0")))%>
<%= Html.DropDownList("drpStartTimem", new SelectList(Model.Minutes, whiteout.StartHour.Minute.ToString("0,0")))%>
<%= Html.DropDownList("drpStartTimet", new SelectList(Model.AMPM, whiteout.StartHour.Hour > 12 ? "PM" : "AM"))%>
-
<%= Html.DropDownList("drpEndTime", new SelectList(Model.Hours, whiteout.EndHour.Hour > 12 ? (whiteout.EndHour.Hour - 12).ToString("0,0") : whiteout.EndHour.Hour.ToString("0,0")))%>
<%= Html.DropDownList("drpEndTimem", new SelectList(Model.Minutes, whiteout.EndHour.Minute.ToString("0,0")))%>
<%= Html.DropDownList("drpEndTimet", new SelectList(Model.AMPM, whiteout.EndHour.Hour > 12 ? "PM" : "AM"))%>
</td>
<td>
<%= Html.DropDownList("drprepeat", new SelectList(Model.RepeatList,whiteout.Repeats))%>
</td>
<td>
Active
</td>
<td>
<a class="icon-button-cancel" href='<%: Url.Action("EditWhiteOut", "Settings", new {Id = whiteout.WhiteoutID}) %>'>
<img src='<%: Url.Content("~/static/Images/expanded.png") %>' alt="Delete this device" />
</a>
<a class="icon-button-success" href="#">
<img src="/static/images/gear.png" alt="Edit this device" /></a>
</td>
<td>
</td>
</tr>
I want to create an object of type Whiteout class and populate it with values selected by user from dropdowns and send to settingcontroller’s EditWhiteout action method instead of passing only new {Id = whiteout.WhiteoutID}. How can I do this ?
Please suggest solution.
Thanks.
Frist of all the link will result in a Get instead of Post. You need to use javascript function attached to the hyperlink to perform a POST to the action on the controller.
please also store the whiteout.whiteoutID in a hidden field.
{
Your Code goes here.
}