How do I not repeat same cell value and keep it blank but display first cell value in a ViewGrid control? RRS feed

  • Question

  • User-337325487 posted

    Hi there,

    I'm using a ViewGrid control and for a project, how do I group by on a unique column value and not showing rest of values after displaying unique group value (for ex: location)?  Displaying every value makes eyes tired...

    Thanks much and any help appreciated.

          Orhan (Business Systems)



    Friday, June 8, 2018 4:35 PM

All replies

  • User1163516801 posted

    Please try following code snippet:

    protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e){
                if (e.Row.RowType != DataControlRowType.DataRow || e.Row.DataItemIndex<1) return;
                var thisRow = e.Row;
                for(int i = 0; i < e.Row.Cells.Count; i++)
                    int index = e.Row.DataItemIndex;
                    int offset = 1;
                    while (index > 0)
                        var upRow = AuthorsGridView.Rows[e.Row.DataItemIndex - offset];
                        if (thisRow.Cells[i].Text == upRow.Cells[i].Text)
                            thisRow.Cells[i].Text = "";

    <audio controls="controls" style="display: none;"></audio>

    Monday, June 11, 2018 9:04 AM