0
Is it possible to sort the values of a dropdown per day?
There is a order by
or have to do really if’s for such?
Code example:
<span class="dropdown">
<button class="btn btn-search dropdown-toggle" type="button" id="horas" data-toggle="dropdown">
<span id="newdisp">Nova disponibilidade</span><span class="caret" style="border-top:4px solid #FFF;"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="horas" onclick="newhour(event);">
@{
foreach (ScriptorContent horas in Model.Parts.Channel[0].Contents)
{
int empresa = (horas.Parts.titulo).LastIndexOf("- ");
if (empresa > 0)
{
string nome = (horas.Parts.titulo).Substring(empresa + 2);
if (nome == a.Parts.empresa[0].Parts.Name)
{
string horainicio = (horas.Parts.inicio).ToString("H:mm");
string horafim = (horas.Parts.fim).ToString("H:mm");
string data = (horas.Parts.inicio).ToString("dd/MM/yyyy");
<li role="presentation"><a role="menuitem" tabindex="-1">@data @horainicio - @horafim</a></li>
}
}
}
}
</ul>
</span>
you could use an order by on your foreach, it would be something like
foreach (ScriptorContent horas in Model.Parts.Channel[0].Contents.OrderBy(a=>a.Campo))
, If it works out, let me know and I’ll put in an answer– Pablo Tondolo de Vargas
@Pablovargas is correct. Put as answers, if there is a problem, you can edit your answer.
– anmaia
I did it differently. I made a queryContents and after that query, I did the orderby, but it wasn’t with lambda Expressions, I did like this: Orderby("$$.title asc") Thanks for your answers.
– n1c0t0p