GridView which formatting is displaying wrong, it display on production system  

<asp:GridView ID="GVBBSTK" runat="server" AutoGenerateColumns="true" OnDataBound="GVBBSTK_DataBound" OnRowCreated="GVBBSTK_RowCreated">
 
        protected void GVBBSTK_DataBound(object sender, EventArgs e)
        {
            for (int i = rowIndex; i < GVBBSTK.Rows.Count; i++)
            {
                wbSubTotal += Convert.ToDecimal(GVBBSTK.Rows[i].Cells[GVBBSTK.Rows[i].Cells.Count - 1].Text);
                bSubTotal += Convert.ToDecimal(GVBBSTK.Rows[i].Cells[GVBBSTK.Rows[i].Cells.Count - 2].Text);
            }
            this.AddTotalRow("Sub Total", bSubTotal.ToString("N2"), wbSubTotal.ToString("N2"));
            this.AddTotalRow("Total", balanceTotal.ToString("N2"), WBalanceTotal.ToString("N2"));
            for (int i = GVBBSTK.Rows.Count - 1; i > 0; i--)
            {
                GridViewRow row = GVBBSTK.Rows[i];
                GridViewRow previousRow = GVBBSTK.Rows[i - 1];
                for (int j = 0; j < row.Cells.Count - 2; j++)
                {
                    if (row.Cells[j].Text == previousRow.Cells[j].Text && row.Cells[j].Text != "0")
                    {
                        if (row.Cells[j].RowSpan == 0)
                        {
                            previousRow.Cells[j].RowSpan += 2;
                        }
                        else
                        {
                            previousRow.Cells[j].RowSpan = row.Cells[j].RowSpan + 1;
                        }
                        row.Cells[j].Visible = false;
                    }
                }
            }
        }
        string currentCategory = "";
        decimal wbSubTotal = 0;
        decimal bSubTotal = 0;
        decimal WBalanceTotal = 0;
        decimal balanceTotal = 0;
        int rowIndex = 0;
        protected void GVBBSTK_RowCreated(object sender, GridViewRowEventArgs e)
        {
            wbSubTotal = 0;
            bSubTotal = 0;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                DataTable dt = (e.Row.DataItem as DataRowView).DataView.Table;
                string category = dt.Rows[e.Row.RowIndex]["Category"].ToString();
                balanceTotal += Convert.ToDecimal(dt.Rows[e.Row.RowIndex]["Balance"]);
                WBalanceTotal += Convert.ToDecimal(dt.Rows[e.Row.RowIndex]["W_Balance"]);
                if (category != currentCategory)
                {
                    if (e.Row.RowIndex > 0)
                    {
                        for (int i = rowIndex; i < e.Row.RowIndex; i++)
                        {
                            wbSubTotal += Convert.ToDecimal(GVBBSTK.Rows[i].Cells[e.Row.Cells.Count - 1].Text);
                            bSubTotal += Convert.ToDecimal(GVBBSTK.Rows[i].Cells[e.Row.Cells.Count - 2].Text);
                        }
                        this.AddTotalRow("Sub Total", bSubTotal.ToString("N2"), wbSubTotal.ToString("N2"));
                        rowIndex = e.Row.RowIndex;
                    }
                    currentCategory = category;
                }
            }
        }
        private void AddTotalRow(string labelText, string balance, string wBalance)
        {
            GridViewRow row = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);
            row.BackColor = ColorTranslator.FromHtml("#F9F9F9");
            row.Cells.AddRange(new TableCell[4] {
                        //new TableCell (), //Empty Cell
                        //new TableCell (), //Empty Cell
                        //new TableCell (), //Empty Cell
                        //new TableCell (), //Empty Cell
                        new TableCell (), //Empty Cell
                        new TableCell { Text = labelText, HorizontalAlign = HorizontalAlign.Right },
                        new TableCell { Text = balance, HorizontalAlign = HorizontalAlign.Right },
                        new TableCell { Text = wBalance, HorizontalAlign = HorizontalAlign.Right } });
            GVBBSTK.Controls[0].Controls.Add(row);
        }