1
Hello! I am trying to receive a filter parameter in my view with the following code on Controller
:
public ActionResult Cadastro(int? idParente)
{
var tab_Documentos_Parente = db.Tab_Documentos_Parente.Where(campo => campo.Id_Parente == idParente).Include(t => t.Tab_Documentos_Cadastrais_Par).Include(t => t.Tab_Parente);
return View(tab_Documentos_Parente.ToList());
}
But when I enter the url: http://localhost:53316/Documentation
Simply does not run the filter. Making a Debug
in the Controller
I see that my parameter is always received as null
.
It is not enough just to inform .../1 at the end of the URL? How then can I send the id I want to filter?
the model is as follows::
public partial class Tab_Documentos_Parente
{
public int Id { get; set; }
[Display(Name = "Nome do Parente")]
public int Id_Parente { get; set; }
[Display(Name = "Descrição do Documento")]
public Nullable<int> Id_Documento { get; set; }
[Display(Name = "Documento")]
[DataType(DataType.Upload)]
public byte[] Documento { get; set; }
public virtual Tab_Documentos_Cadastrais_Par Tab_Documentos_Cadastrais_Par { get; set; }
public virtual Tab_Parente Tab_Parente { get; set; }
}
Alam, you set the course for her to understand
/1
is a parameter?– Leonardo Bonetti
Try with the url
http://localhost:53316/Documentos_Parente/Cadastro?idParente=1
if it works it’s because you didn’t set the route correctly.– Leonardo Bonetti
You’re right @Leonardobonetti the url you suggested worked. But how it works with the Edit and Delete Views generated by Scaffold, I figured it would just follow the same template. Where I set up this route?
– AlamBique
I’ll create a fucking answer, wait for me.
– Leonardo Bonetti
Kkkkk! Waiting for good...
– AlamBique