Вопрос

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.

Это было полезно?

Решение

Use AddAt(int index, TableCell cell) instead

Example:

e.Row.Cells.AddAt(2, cell1);

Hope this will help !!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top