Asp.net gridview rowupdated event e.Tow.RowType type?

136 Views Asked by At

I have some code in GridView1_RowDataBound event for html design of table :

if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.TableSection = TableRowSection.TableHeader;

        }
        else if (e.Row.RowType == DataControlRowType.DataRow)
        {
            TableCellCollection cell = e.Row.Cells;
            cell[0].Attributes.Add("data-title", "");
            cell[1].Attributes.Add("data-title", "Product"  

        }

After row update I need do this again but I can't. Because RowUpdated EventArgs has no Row property. How can I solve this ?

1

There are 1 best solutions below

3
VDWWD On BEST ANSWER

You can loop the GridView rows outside the RowDataBound event also.

foreach (GridViewRow row in GridView1.Rows)
{
    TableCellCollection cell = row.Cells;
    cell[0].Attributes.Add("data-title", "");
    cell[1].Attributes.Add("data-title", "Product");
}

You can access the header row with this

GridView1.HeaderRow.Cells[0].Attributes.Add("data-title", "");