Link to home
Start Free TrialLog in
Avatar of Lorna70
Lorna70

asked on

Code removing the wrong cells - how do I get the value of a cell in GridView

Hi I'm trying to add rowspan to the first cell in a group and then removing the subsequent cells but my code seems to be removing the wrong cells (e.g gvr.Cells.RemoveAt(0);).  How can I get the value of a cell in the following code so I can determine which cells are actually being removed??

foreach (GridViewRow gvr in gvWeeksCatches.Rows)
        {
            gvRowIndex = gvr.RowIndex;
            if (gvRowIndex == firstSpanRow)
            {
                gvr.Cells[0].RowSpan = numSpanRows;
                gvr.Cells[1].RowSpan = numSpanRows;
            }
            //if row is in rowspan group
            else if (gvRowIndex > firstSpanRow && gvRowIndex <= lastSpanRow)
            {
                gvr.Cells.RemoveAt(0);
                gvr.Cells.RemoveAt(1);
               
            }
            gvRowIndex++;

        }
ASKER CERTIFIED SOLUTION
Avatar of lojk
lojk
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lorna70
Lorna70

ASKER

Thank you so much - I've been tearing my hair out for weeks on this! :-)
It was a bit of a glaring error but I've been down this road with similar issues so many times before - sometimes you just need a fresh pair of eyes on the subject.

Glad to have saved some of your hair, even if it's too late for mine. ;-)