Method is not properly working when ASP.NET GridView Index gets changed
07:39 06 Aug 2015

I have a method which is executed when the page is loaded and when the page of the gridview is changed. This method imports the data, as well setting the rowspans. The data import is working on every site but the Rowspan only gets set on the first page.
This is my C# Code:

 protected void grdvProductChurn_DataBound()
{
    for (int rowIndex = grdvProductChurn.Rows.Count - 2; rowIndex >= 0; rowIndex += -1)
    {
        GridViewRow gvRow = grdvProductChurn.Rows[rowIndex];
        GridViewRow gvPreviousRow = grdvProductChurn.Rows[rowIndex + 1];
        for (int cellCount = 0; cellCount <= gvRow.Cells.Count - 8; cellCount++)
        {
            if (gvRow.Cells[cellCount].Text == gvPreviousRow.Cells[cellCount].Text)
            {
                if (gvPreviousRow.Cells[cellCount].RowSpan < 2)
                {
                    gvRow.Cells[cellCount].RowSpan = 2;
                }
                else
                {
                    gvRow.Cells[cellCount].RowSpan = gvPreviousRow.Cells[cellCount].RowSpan + 1;
                }
                gvPreviousRow.Cells[cellCount].Visible = false;
            }
        }
    }

    if (grdvProductChurn != null)
    {
        GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
        TableHeaderCell left = new TableHeaderCell();
        left.Text = "";
        left.ColumnSpan = 2;
        row.Cells.Add(left);



        TableCell totals = new TableHeaderCell();
        totals.ColumnSpan = grdvProductChurn.Columns.Count - 2;
        totals.Text = "Anzahl";
        row.Cells.Add(totals);
      

    }

}

And this is my asp GridView:

     

Then I also have the method for the onpageindexchanged. It gets executed when I change the page, but the rowspan doesn't work.

   public void grdvProductChurn_PageIndexChanged(object sender, EventArgs e)
    {
        grdvProductChurn_DataBound();
        
    }

The gridview is a simple view, it doesn't provide an option to change or interact with it beyond paging

c# asp.net gridview