I'm current working on making a sort of wiki of plants. The first thing we started doing is the managment of the users in the site. For that we made this view that shows the results of a search from the database. The search works fine and the ViewData["datos"] returns what it should, and in this table we show the users (From the Model Usuario). In the end, for each user it should show a button that sends the Model for that user to another Controller. The problem is that the Controller receives an empty model. Here's the code for the View. The input with the value Editar is the one that should send the model.
@model AtlasPlantasMedicinales.Models.Usuario
@{
ViewBag.Title = "Tabla";
}
@if (ViewData["datos"]!=null){
<table>
@foreach (var elemento in (List<AtlasPlantasMedicinales.Models.Usuario>)(ViewData["datos"]))
{
<tr>
<td>
@elemento.Nombre
</td>
<td>
@elemento.Carrera
</td>
<td>
@elemento.Institucion
</td>
<td>
@elemento.usuario
</td>
<td>
@elemento.correo
</td>
@using (Html.BeginForm("FormularioEditar", "Usuario", FormMethod.Post))
{
<td>@Html.HiddenFor(m => elemento) <input type="submit" value="Editar"></td>
}
</tr>
}
</table>
}
How can we send the model in elemento to the controller?
We have also tried making a Html.HiddenFor for each attribute in the model, but it still doesn't work. Please keep in mind that me (and my teammmates) are completely new at ASP.NET MVC 4