2
I’m studying ASP.NET MVC5, so I did one Model
called 'Reporteriotagmodels' containing:
public class RelatorioTagModels
{
[Key]
public int TagID { get; set; }
[Required]
public string Tag { get; set; }
[Required]
public string Vedacao { get; set; }
[Required]
public string Fluido { get; set; }
[Required]
public string Criticidade { get; set; }
[Required]
public decimal Mtbf { get; set; }
}
View do Model RelatorioTagModels
body>
<p>
@*@Html.ActionLink("Create New", "Create")*@
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.Tag)
</th>
<th>
@Html.DisplayNameFor(model => model.Fluido)
</th>
<th>
@Html.DisplayNameFor(model => model.Vedacao)
</th>
<th>
@Html.DisplayNameFor(model => model.Criticidade)
</th>
<th>
@Html.DisplayNameFor(model => model.Mtbf)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<th>
@Html.DisplayFor(modelItem => item.Tag)
</th>
<td>
@Html.DisplayFor(modelItem => item.Fluido)
</td>
<td>
@Html.DisplayFor(modelItem => item.Vedacao)
</td>
<td>
@Html.DisplayFor(modelItem => item.Criticidade)
</td>
<td>
@Html.DisplayFor(modelItem => item.Mtbf)
</td>
<td>
@Html.ActionLink("Detalhes", "Index", "RelatorioRa")
</td>
</tr>
}
</table>
By Scaffoding, I ran the Controller
and the Views
, where, by clicking on Detalhes
, I am directed to another table, where in this table, I would like to list only the records that contain the Tag
model’s RelatorioTagModels
.
So I created another model called: RelatorioRaModels
:
public class RelatorioRaModels
{
[Key]
public int RaID { get; set; }
[Required]
public string Data { get; set; }
[Required]
public string Nivel { get; set; }
[Required]
public string Nº { get; set; }
[Required]
public string Tag { get; set; }
}
That by Scaffoding, I created the Controller
and the Views
My question is, how to list on the model RelatorioRaModels
only the records of the TAG selected in the model RelatorioTagModels
Updating:
Model view: RelatorioTagModels
By clicking on the link Detalhe
of the first line, I would like to list only the records that belong to the TAG P401-1E
, but, at the moment, it brings the whole table.
Update: Actionresult of Detailing Method:
[Authorize]
public async Task<ActionResult> Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
RelatorioTagModels relatorioTagModels = await db.RelatorioTagModels.FindAsync(id);
if (relatorioTagModels == null)
{
return HttpNotFound();
}
return View(relatorioTagModels);
}
Updating:
By clicking detail in the first report (RelatorioTagModels
) I am directed to the Index
of the second report (RelatorioRaModels
), where I want to show only the records that belong to that TAG.
If I go back in the first report, click on details of another TAG, I am directed to the second report, where I need it to show only the TAG records that were selected in the first report.
It’s like I’m making a WHERE
in SQL. How do I do this WHERE
when calling the index of the model RelatorioRaModels
Like this? http://answall.com/questions/102939/guardar-e-enviar-id-de-item-selected-no-dropdowlinst/102945#102945
– Leonel Sanches da Silva
It’s not really a survey, I’ll improve the question, thank you
– Thomas Erich Pimentel
Edit your question and put the
ActionResult
of the method of Detailing.– Marllon Nasser
Friend, I updated the question as requested
– Thomas Erich Pimentel
I don’t understand why you save the report in bank.
– Leonel Sanches da Silva
@The first report generated by the Reporteriotagmodels model is dynamic, the MTBF field is calculated from another application of mine! The second report, generated by the Reporterioramodels model has all the dates and number of each update, and in this second report (Reporterioramodels) I want to "filter", to bring only the TAG records that was clicked on the first report (Reporteriotagmodels)-
– Thomas Erich Pimentel
You want to return all records of the same tag, as if it were a
select * from RelatorioTagModels where Tag = 'P401-1E'
?– Pablo Tondolo de Vargas
@Pablovargas exact friend, that’s right, only I want to use the table
RelatorioRaModels
– Thomas Erich Pimentel
So basically the link that @Ciganomorrisonmendez put in the first comment. But I will prepare an example and go up on github with your case
– Pablo Tondolo de Vargas
Man, if you could do that, it would help me a lot. but I’ll read again the link from Gypsy thank you
– Thomas Erich Pimentel
Just to understand, a Reporteriotagmodels has several Reporterioramodels?
– Pablo Tondolo de Vargas
Let’s go continue this discussion in chat.
– Thomas Erich Pimentel