serdar
serdar

Reputation: 454

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

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 ?

Upvotes: 0

Views: 165

Answers (1)

VDWWD
VDWWD

Reputation: 35514

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", "");

Upvotes: 2

Related Questions