1
I have a Foreach in View, and it contains Description, Qtd and dta,how do I make a foreach without repeating the description? Ex: I have a product X whose were removed 10 units day 01/10/2016, 3 units day 04/10/2016, 8 units day 15/10/2016, how do I display the description once and the dates and quantities normally?
<style type="text/css">
.leftDivItem, .rightDivItem {
border: none;
float: left;
width: 29%; /*Aumentar ou diminuir a porcentagem para adicionar ou tirar*/
overflow: hidden;
margin-right: 2%;
margin-left: 2%;
float: left;
width: 19%;
overflow: hidden;
margin-right: 3%;
margin-left: 3%;*/
}
</style>
int i = 0;
foreach (var item in Model)
{
if (i % 2 == 0)
{
<div class="leftDivItem">
<span class="listCol2">
<i>@Html.DisplayFor(modelItem => item.Produto.Descricao)</i><br />
<i>@Html.DisplayFor(modelItem => item.Produto.Qtd)</i><br />
<i>@Html.DisplayFor(modelItem => item.Produto.dta)</i>
<br />
<br />
</span>
</div>
}
else
{
<div class="rightDivItem" id="textShadow">
<span class="listCol2">
<i>@Html.DisplayFor(modelItem => item.Produto.Descricao)</i><br />
<i>@Html.DisplayFor(modelItem => item.Produto.Qtd)</i><br />
<i>@Html.DisplayFor(modelItem => item.Produto.dta)</i>
<br />
<br />
</span>
</div>
}
i++;
}
in the code I’m showing, the
<i>@Html.DisplayFor(modelItem => item.Produto.Descricao)</i><br />
and I know he’ll repeat himself several times because he’s there, but I wanted to know how I position him not to repeat, and yes appear only once! Grateful!
It worked, but I was wondering how do I sort by the amount?
– Fabio Souza
In case it would be so, it comes ordered by description, and each description has various quantities and dates, wanted in addition to sort by description, sort also by quantity. Ex: Product X - 10 units - 01/10/2016 3 units - 04/10/2016 8 units - 15/10/2016
– Fabio Souza
Product Y - 2 units - 01/10/2016 30 units - 04/10/2016 8 units - 15/10/2016 were ordered by quantity... so: Product X - 10 units - 01/10/2016 8 units - 15/10/2016 3 tokens - 04/10/2016 Product Y - 30 tokens - 04/10/2016 8 tokens - 15/10/2016 2 tokens - 01/10/2016
– Fabio Souza
@Fabiosouza I edited the answer
– Bruno Costa
Thank you. saved my skin rs
– Fabio Souza
@Fabiosouza If I helped, vote and accept the answer.
– Bruno Costa
Sorry, I’m new here, I don’t understand much about how the site works... I accepted the answer, but how do I vote?
– Fabio Souza
@Fabiosouza He has two arrows very close to accepting, one down (vote against) and the other up (positive vote). Take the tour
– Bruno Costa
when I click to vote it appears this message
– Fabio Souza
Thanks for the feedback! Votes cast by those with Less than 15 Reputation are Recorded, but do not change the publicly displayed post score
– Fabio Souza
@Fabiosouza Sheltered by the warning Fabio. I will ask the community to translate the message. " Thanks for the feedback! Votes of users with less than 15 reputations are saved, but do not change the count of votes of post". I mean, don’t worry.
– Bruno Costa