
The code is not calculating total paid and total unpaid inside gridview.
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" ForeColor="#333333" GridLines="None"  Class="table table-striped table-bordered table-hover" 
            onrowcancelingedit="GridView1_RowCancelingEdit" 
            onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating" 
            onrowdatabound="GridView1_RowDataBound">
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <Columns>
               <asp:TemplateField HeaderText="Invoice No.">
               <ItemTemplate >
                   <asp:Label ID="lbl_AdNo" runat="server" Text='<%# Eval("InvoiceNo") %>' ></asp:Label>
               </ItemTemplate>
               </asp:TemplateField>
                <asp:TemplateField HeaderText="Invoice Date">
                <ItemTemplate >
                    <asp:Label ID="lbl_Date" runat="server" Text='<%# Eval("InvoiceDate") %>'></asp:Label>
                </ItemTemplate>
               
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Grand Total">
                <ItemTemplate >
                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("GrandTotal") %>'></asp:Label>
                </ItemTemplate>
               
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Customer Name">
                <ItemTemplate >
                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("CName") %>'></asp:Label>
                </ItemTemplate>
               
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Phone No.">
                <ItemTemplate >
                  <asp:Label ID="Label4" runat="server" Text='<%# Eval("CPhone") %>' ></asp:Label>
                </ItemTemplate>
                
                    </asp:TemplateField>
                                        
              
                <asp:TemplateField HeaderText="Status">
                <ItemTemplate >
                    <asp:Label ID="Label6" runat="server" Text='<%# Eval("Status") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate >
                     <asp:CheckBoxList ID="chkStatus" runat="server" s>
                         <asp:ListItem>Paid</asp:ListItem>
                         <asp:ListItem>Unpaid</asp:ListItem>
                     </asp:CheckBoxList>
                </EditItemTemplate>
                </asp:TemplateField>
                
                 <asp:TemplateField HeaderText="Edit" ShowHeader="false">
                    <ItemTemplate>
                        <asp:LinkButton ID="btnedit" runat="server" CommandName="Edit" Text="Edit" ></asp:LinkButton>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:LinkButton ID="btnupdate" runat="server" CommandName="Update" Text="Update" ></asp:LinkButton>
                        <asp:LinkButton ID="btncancel" runat="server" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                    </EditItemTemplate>
                  </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#CCCCCC" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:GridView>
 
    private void BindGrid()
    {
        con = new SqlDbConnect();
        con.SqlQuery("select InvoiceNo,InvoiceDate,GrandTotal,CName,CPhone,Status from tblSales order by InvoiceNo Desc;");
        adapt.SelectCommand = con.Cmd;
        adapt.Fill(sTable);
        if (sTable.Rows.Count > 0)
        {
            GridView1.DataSource = sTable;
            GridView1.DataBind();
            lblTotal.Text = GridView1.Rows.Count.ToString();
            
            int Paid = 0;
            int Unpaid = 0;
         
            foreach (GridViewRow row in this.GridView1.Rows)
            {
                if (row.Cells[5].Text == "Paid")
                {
                    Paid++;
                }
                if (row.Cells[5].Text == "Unpaid")
                {
                    Unpaid++;
                }                
            }
            this.lblPaid.Text = Paid.ToString();
            this.lblUnpaid.Text = Unpaid.ToString();
        }
        else
        {
            Response.Write("No Record Found");
            return;
        }
        con.conClose();
    }