0

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 Answer 1

2

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", "");
Sign up to request clarification or add additional context in comments.

3 Comments

Yeah right. Thank you but it doest work for header type. if (e.Row.RowType == DataControlRowType.Header) { e.Row.TableSection = TableRowSection.TableHeader; }
Updated my answer. You can access the header row also.
I changed your answer a bit. I removed if statement " if (e.Row.RowType == DataControlRowType.Header)" and just used : GridView1.HeaderRow.TableSection = TableRowSection.TableHeader; Of course your answer was right. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.