I have a view that corresponds to a survey. It is loaded with the questions and at the same time in the last column has a DropDowList with the possible answers. The problem I have is that I can not get my controller to receive the data of the questions and answers.
View:
@using (Html.BeginForm("CompetenciasEspecificas", "VDTCabecera",Model,
FormMethod.Get, new { @class = "form-horizontal" }))
{
<div id="block1">
<fieldset>
<legend class="text-center header">Competencias Cardinales</legend>
<legend class="text-center header">@ViewBag.Message</legend>
</fieldset>
</div>
<table class="table" style="table-layout:fixed">
<tr>
<th width="50" height="16">
@Html.DisplayNameFor(model => model.Item)
</th>
<th width="200" height="16">
@Html.DisplayNameFor(model => model.Descripcion)
</th>
<th width="100" height="16"></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<b>@Html.DisplayFor(modelItem => item.Item)</b>
</td>
<td>
<p>@Html.DisplayFor(modelItem => item.Descripcion)</p>
</td>
<td>
@{
List<SelectListItem> listItems = new List<SelectListItem>();
listItems.Add(new SelectListItem
{
Text = "4 (Grado Alto)",
Value = "4",
Selected = true
});
listItems.Add(new SelectListItem
{
Text = "3 (Bueno por encima del estandar)",
Value = "3"
});
listItems.Add(new SelectListItem
{
Text = "2 (Minimo necesario para el puesto)",
Value = "2"
});
listItems.Add(new SelectListItem
{
Text = "1 (Insatisfactorio)",
Value = "1"
});
}
<div class="form-group">
<div class="col-md-10">
@Html.DropDownListFor(modelItem => item.Calificacion, listItems, null, htmlAttributes: new { @class = "form-control", Title = "Estado en el cual se encuentra la parametrización actual" })
@Html.ValidationMessageFor(modelItem => item.Calificacion, "", new { @class = "text-danger" })
</div>
</div>
</td>
</tr>
}
</table>
<div class="form-group">
<div class="col-md-12 text-center">
<input type="submit" value="Siguiente página" class="btn btn-primary btn-lg" />
</div>
</div>
}
Controller:
public ActionResult CompetenciasEspecificas(List<VDTAnalisisHabReqModel> collection)
{
try
{
// TODO: Add insert logic here
if (ModelState.IsValid)
{
HabilidadesRequeridasServices srvhab = new HabilidadesRequeridasServices();
List<VDTAnalisisHabReqModel> list = new List<VDTAnalisisHabReqModel>();
/*
foreach (VDTAnalisisHabReqModel a in collection)
{
srvhab.InsertarDetalleHabilidad(a);
}
*/
/*list = srvhab.ObtenerHabilidadesEspecificas(collection[0].FuncionarioId);
for (int i = 0; i < list.Count; i++)
{
list[i].DatosFuncionario = collection[0].DatosFuncionario;
list[i].VdtId = collection[0].VdtId;
}
ViewBag.Message = collection[0].DatosFuncionario;*/
return View(list);
}
return View();
}
catch
{
return View();
}
}