locked
Remove Border With For Footer Gridview row RRS feed

  • Question

  • User2033107836 posted

    Hi

    I'm using This code

     protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            foreach (TableCell cell in e.Row.Cells)
            {
                cell.BorderColor = System.Drawing.Color.Black;
                cell.BorderWidth = new Unit(2);
                cell.BorderStyle = BorderStyle.Solid;
            }

    its showing border for all, but i dont want to put for footer template how to remove so

    Wednesday, February 22, 2017 8:41 AM

Answers

  • User-1509636757 posted

    You can do that by making use of HeaderStyle, ItemStyle and FooterStyle for TemplateField. Here is one example:

    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" ShowFooter="true" GridLines="None">
        <Columns>
            <asp:TemplateField>
                <HeaderTemplate>
                    <asp:CheckBox ID="chkHeader" runat="server" CssClass="chkHeader" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chkSelect" runat="server" CssClass="chkSelect" />
                </ItemTemplate>
                <FooterTemplate>
                    Test1
                </FooterTemplate>
                <FooterStyle BorderStyle="None" />
                <ItemStyle BorderStyle="Solid" />
                <HeaderStyle BorderStyle="Solid" />
            </asp:TemplateField>
    
            <asp:TemplateField HeaderText="QPP" SortExpression="QPP">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("QPP") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" CssClass="Label7" runat="server" Text='<%# Bind("QPP") %>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    Test2
                </FooterTemplate>
                <FooterStyle BorderStyle="None" />
                <ItemStyle BorderStyle="Solid" />
                <HeaderStyle BorderStyle="Solid" ForeColor="Teal" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

    Output:

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 22, 2017 9:34 AM