需要通过代码(C#)填充一个gridview,并想知道我如何定义其中声明的组件的值,如标签、按钮和链接按钮。下面是一个可以填充但我没有得到的组件示例:
<asp:Label ID="lbCodigo" CssClass="label label-inverse" runat="server" Text='<%#Eval("CODIGO") %>'></asp:Label>
下面是完整的网格视图:
<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>