How to create a GridView

0

The examples I saw on the net none worked, or were very personalized. I just want a simple table with 4 columns that will be populated with data from a bd. The same will be within a simple modal:

<div class="modal fade open" id="modalVersao" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog">

                            <div class="modal-content">
                                <div class="modal-header" >
                                    <button type="button" class="close" data-dismiss="modal"  aria-hidden="true">&times;</button>
                                    <h4 class="modal-title">
                                        <asp:Label ID="Label3" runat="server" Text="Gerenciar Versões"></asp:Label></h4>
                                </div>

                                <div class="modal-body">

         <!-- Quero o GRID aqui -->

                                                                                     </div>
                                <div class="modal-footer">
                                    //Botoes
                                </div>    
    
asked by anonymous 16.03.2015 / 21:54

1 answer

1

EDIT

You can easily complete your task with table HTML and foreach (or for if you prefer). You can still do this with asp:gridview or asp:repeater (also using table in case of repeater ). An intermediate between the two is asp:ListView .

An example with Repeater :

<table>
    <asp:Repeater ID="Repeater" runat="server">
        <HeaderTemplate>
            <tr>
                <td>Código</td>
                <td>Nome</td>
                <td>Descrição</td>
                <td>Categoria</td>
                <td>Preço Unitário (R$)</td>
            </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td><%# Eval("Id") %></td>
                <td><%# Eval("Nome") %></td>
                <td><%# Eval("Descricao") %></td>
                <td><%# Eval("Categoria") %></td>
                <td><%# Eval("PrecoUnitario") %></td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            <tr>
                <td>Foo</td>
                <td>foo</td>
                <td>FOO</td>
                <td>fOO</td>
                <td>ooF</td>
            </tr>
        </FooterTemplate>
    </asp:Repeater>
</table>

In C #:

List<Produto> produtos = ProdutoService.GetProdutos();
this.Repeater.DataSource = produtos;
this.Repeater.DataBind();

About Repeater , you can find more information here: link

Another useful resource:

I hope this helps, but feel free to share more information about it.

    
17.03.2015 / 13:58