Question

need to fill a gridview via code (C#) and want to know how I define the values ​​for components declared inside of it, like labels, buttons and linkbuttons. Below is an example of a component that would fill and I'm not getting:

<asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Eval("CODIGO") %>'></asp:Label>

Below is the complete gridview:

<asp:GridView ID="gridContatos" runat="server" AutoGenerateColumns="False" Width="100%" OnRowCommand="gridContatos_RowCommand" OnRowDataBound="gridContatos_RowDataBound" CssClass="table table-condensed" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
        <AlternatingRowStyle BackColor="#c0c0c0" />
        <Columns>
            <asp:TemplateField HeaderText="CAIXA DE ENTRADA - FALE CONOSCO">
                <ItemTemplate>
                    <div class="container">
                        <div class="row-fluid">
                            <div class="span2">
                                <div class="">
                                    <div class="alert label-inverse">
                                        <asp:Label ID="lblbAutor" CssClass="label label-info" runat="server" Text='<%#Eval("NOME") %>'></asp:Label>
                                    </div>
                                </div>
                            </div>
                            <div class="span7">
                                <div class="">
                                    <div class="alert label-inverse">
                                        <asp:Label ID="lbAssunto" CssClass="label label-success" runat="server" Text='<%#Eval("ASSUNTO") %>'></asp:Label>
                                    </div>
                                </div>
                            </div>
                            <div class="span3">
                                <div class="alert label-inverse">
                                    <asp:LinkButton ID="lbVisualizar" CssClass="label label-success" Visible="true" runat="server" Text="VER" ToolTip="Responder" CommandName="Visualizar" CommandArgument='<%# Container.DataItemIndex%>' />
                                    <%--<asp:ImageButton ID="imgVisualizar" runat="server" ImageUrl="~/Images/zomin_128x128.png" Width="20px" Height="25%" ToolTip="Responder" CommandName="Visualizar" CommandArgument='<%# Container.DataItemIndex%>' />--%>
                                    <asp:LinkButton ID="lbResponder" runat="server" CssClass="label label-inverse" ToolTip="Responder" Visible="true" Text="RESPONDER" CommandName="Responder" CommandArgument='<%# Container.DataItemIndex%>' />
                                    <asp:LinkButton ID="lbExcluir" runat="server" CssClass="label label-warning" Visible="true" Text="EXCLUIR" ToolTip="Excluir" CommandName="Excluir" CommandArgument='<%# Container.DataItemIndex%>' />
                                </div>
                            </div>
                        </div>
                    </div>
                    <br />
                    <asp:Panel ID="pnMensagem" runat="server" CommandArgument='<%# Container.DataItemIndex%>' Visible=" false">
                        <hr />
                        <div class="container">
                            <div class="row">
                                <div class="span4">
                                    <div class="caption">
                                        <asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Eval("CODIGO") %>'></asp:Label>
                                        <br />
                                        <asp:Label ID="lbData" CssClass="label label-inverse" runat="server" Text='<%#Eval("DATAENVIO") %>'></asp:Label>
                                        <br />
                                        <asp:Label ID="lbEmail" CssClass="label label-inverse" runat="server" Text='<%#Eval("EMAIL") %>'></asp:Label>
                                        <br />
                                        <asp:Label ID="lbTelefone" CssClass="label label-success" runat="server" Text='<%#Eval("TELEFONE") %>'></asp:Label>
                                        <br />
                                        <asp:Label ID="lbEndereco" CssClass="label label-success" runat="server" Text='<%#Eval("ENDERECO") %>'></asp:Label>
                                        <br />
                                        <asp:Label ID="lbCidade" CssClass="label label-success" runat="server" Text='<%#Eval("CIDADE") %>'></asp:Label>

                                        <%-- <br />
                                        <asp:Label ID="lbCelular" CssClass="label label-inverse" runat="server" Text='<%#Eval("celular") %>'></asp:Label>--%>
                                    </div>
                                </div>
                                <div class="span8">
                                    <div class="caption">
                                        <asp:TextBox Width="95%" ID="txtMensagem" runat="server" Text='<%#Eval("MENSAGEM") %>' Enabled="false" TextMode="MultiLine"
                                            Rows="5"></asp:TextBox>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </asp:Panel>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle />
        <HeaderStyle />
        <PagerStyle HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle />
        <SortedAscendingHeaderStyle />
        <SortedDescendingCellStyle />
        <SortedDescendingHeaderStyle />
    </asp:GridView>
Was it helpful?

Solution

I did not understood your question well but i hope this is what you are asking for .

<asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Bind("CODIGO") %>'></asp:Label>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top