How to make a grouping in View Asp.net mv

Asked

Viewed 79 times

0

I have a consultation with grouping with the following result:

inserir a descrição da imagem aqui

In my Controller I have :

// 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>
            }

    }
  • 1

    I don’t understand what you want !

1 answer

0

Use LINQ: Groupby()

var listar = tbuscar.ListarTodos("S","S").GroupBy(p => p.IDCATEGORIAVIDEO);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.