我需要在页脚模板中相互低于总数。在包含数据的行到第5列之后应该没有网格线,然后在Total Col。之后再次出现网格线。
这是ASPX代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SelectedRowStyle-BackColor="AliceBlue"
ShowFooter="True" EnableModelValidation="True"
onrowdatabound="LineItemGrid_RowDataBound" onrowcommand="GridView1_RowCommand" CellSpacing="0"
style="border-width:2px;border-style:Solid;font-weight:bold;width:1050px;">
<Columns>
<asp:TemplateField HeaderText="xxx">
<ItemTemplate>
<asp:Label ID="lbl1" runat="server" Text='Label' ></asp:Label>
</ItemTemplate>
<asp:TemplateField HeaderText="yyyy">
<ItemTemplate>
<asp:Label ID="lbl2" runat="server" Text='Label' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
///....Two other template fields here....
</asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbltotal" runat="server" Text='' ></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server" ID="txttotalprice" ReadOnly="true" Width="100px" BorderStyle="None" ></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
请求帮助我如何在页脚模板中应用下面所需的格式....
答案 0 :(得分:0)
订阅GridView_RowDataBound事件
然后您可以执行以下操作:
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for(int i = 0; i < e.Row.Cells.Count; i++)
{
if(i > 5)
{
e.Row.Cells[i].CssClass = "CellBorder";
}
}
}
}
您需要使用索引和条件(以及CSS!)