Reputation: 783
I have gridview with autogenerated columns.I have added a column dynamically in the row databound event.
if (e.Row.RowType == DataControlRowType.DataRow)
{
TableCell cell1 = new TableCell();
e.Row.Cells.Add(cell1);
}
// to add header
else
{
TableCell cell1 = new TableCell();
cell1.Text = "<span style='font-weight:bold'>NAME";
e.Row.Cells.Add(cell1);
}
This column gets added at the end. I want to add this column in the index 2.
Any one can help me please? Thanks in Advance.
Upvotes: 1
Views: 935
Reputation: 14302
Use AddAt(int index, TableCell cell) instead
Example:
e.Row.Cells.AddAt(2, cell1);
Hope this will help !!
Upvotes: 2