I have a update stored proc that updates the DisplayTestimonials field in the database based on what the users checks on the form. How would I update the checked field in the database in my controller? I guess i would have to use controller to call that update stored procedure, right? I am not sure how would i pass the values from a foreach loop in a controller. Any help?
This is my View.
@model Models.SurveyTestimonials
@{
Layout = "~/CustomViews/cap/Shared/_DealerLayout.cshtml";
}
@section Tags {
@Html.UserControl("Header", new { id = Model.Channel.ChannelId })
}
@section Menu {
@Html.ActionLink("Premier Dealer", "Index", "Premier", new { area = "Apps" }, new { })
}
<h2>Manage Survey Testimonials</h2>
@using (Html.BeginForm())
{
<div>
<table>
<thead>
<tr>
<td>Select</td>
<td>First Name</td>
<td>Last Name</td>
<td>Testimonial</td>
</tr>
</thead>
@foreach (var testimonials in Model.Testimonials)
{
<tr>
<td>@Html.CheckBox("" + testimonials.DisplayTestimonials)
@Html.Hidden(testimonials.ResponseId.ToString())
</td>
<td>@Html.Label(testimonials.FirstName)</td>
<td>@Html.Label(testimonials.LastName)</td>
<td>@Html.Label(testimonials.Question5Answer)</td>
</tr>
}
<tr>
<td colspan="3">
<input type="submit" id="Submit" value="Save" class="PremireButton" />
</td>
</tr>
</table>
</div>
}