Personal I need a help to understand where I'm going wrong and how to fix a problem. I do not handle a lot of MVC, but I'm turning here.
I need to pass a Model class as a parameter to an ActionResult, but the variable is being sent empty.
My Index ()
@model IEnumerable<Sistemas.Digital.Model.PoderesPJ.Poder>
@{
ViewBag.Title = "Poderes";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@*@using (Html.BeginForm())
{
*@<fieldset>
<legend></legend>
<h2>Poderes</h2>
<table class="table">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.Nome)</th>
<th>@Html.DisplayNameFor(model => model.Codigo)</th>
<th>@Html.DisplayNameFor(model => model.Inicio)</th>
<th>@Html.DisplayNameFor(model => model.Vencimento)</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Nome)</td>
<td>@Html.DisplayFor(modelItem => item.Codigo)</td>
<td>@Html.DisplayFor(modelItem => item.Inicio)</td>
<td>@Html.DisplayFor(modelItem => item.Vencimento)</td>
<td>@Html.ActionLink("Detalhes", "Detalhes", new { item = item.Detalhes })</td>
</tr>
}
</tbody>
</table>
</fieldset>
My method on the Controller
public ActionResult Detalhes(PoderesPJ.Detalhes item)
{
return View(item);
}
The problem I believe is in ActionLink, which does not send the completed Class.
Full Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Sistemas.Digital.Model;
using Sistemas.Digital.GERAL;
using Util.Crawler;
namespace Aplicativos.CockPit.Controllers
{
public class PoderController : Controller
{
//
// GET: /Poder/
List<PoderesPJ.Poder> listaPoder;
Crawler cr = new Crawler();
private List<PoderesPJ.Poder> ListaPoderes(string agencia, string conta, ref Crawler cr)
{
List<PoderesPJ.Poder> _poderes = new List<PoderesPJ.Poder>();
ConsultaPoderesPJ consulta = new ConsultaPoderesPJ();
_poderes = consulta.ConsultaPoderesAgenciaConta(ref cr, agencia, conta);
return _poderes.OrderBy(d => d.Nome).ToList();
}
public ActionResult Index()
{
string _param1 = "1234";
string _param2 = "456789";
listaPoder = ListaPoderes(param1, param2, ref cr);
return View(listaPoder);
}
public ActionResult Detalhes(PoderesPJ.Detalhes item)
{
return View();
}
}
}