How to do a grouping in View asp.net mv

0

I have a query with grouping with the following result:

InmyControllerIhave:

// GET public ActionResult Index() { //lista var tbuscar = new GaleriaVideoAplicacao(); var listar = tbuscar.ListarTodos("S","S"); return View(listar); }

In view:

@model IEnumerable<Generico.Dominio.TB_GALERIA_VIDEO>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}



@if (Model.Count() > 0)
{

    foreach (var item in Model)
    {

            <div class="container-fluid">
                <div class="panel-group" id="accordion">

                    <div class="panel panel-default">

                        <div class="panel-heading">
                            <h4 class="panel-title">
                                <a data-toggle="collapse" data-parent="#accordion" href="#@item.IDCATEGORIAVIDEO">@item.DESCRICAOCATEGORIA </a>
                            </h4>
                        </div>

                        <!--conteúdo repetir de acordo com o agrupamento-->


                        <div  id="@item.IDCATEGORIAVIDEO" class="panel-collapse collapse in"> <!--id categoria-->
                            <div class="panel-heading">
                                <strong> @Html.Label("Jads e Jadson 2015 Ao Vivo") </strong><br />
                                <a href="@Url.Action("ExcluirVideo", "CadastroGaleriaVideo", new {id = @item.IDVIDEO })" class="btn btn-success"> Editar </a>
                                <a href="@Url.Action("ConsultarVideo", "CadastroGaleriaVideo",new {id = @item.IDVIDEO })" class="btn btn-danger"> Excluir </a>
                            </div>

                                <div class="panel-body">
                                    <iframe width="560" height="315"
                                            [email protected]
                                            frameborder="0" allowfullscreen></iframe>

                                    <audio controls="controls"
                                           loop preload="preload"
                                           title="Jads e Jadson 2015 Ao Vivo">
                                        <source type="audio/mpeg" src="~/Content/audios/on000011.mp3" />
                                    </audio>
                                </div>
                        </div> <!--fim categoria-->

                        <!--conteúdo repetir de acordo com o agrupamento-->

                    </div>

                </div>


            </div>
            }

    }
    
asked by anonymous 29.10.2016 / 19:07

1 answer

0

Use LINQ: GroupBy ()

var listar = tbuscar.ListarTodos("S","S").GroupBy(p => p.IDCATEGORIAVIDEO);
    
30.10.2016 / 02:46