Pergunta

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.

Foi útil?

Solução

Use AddAt(int index, TableCell cell) instead

Example:

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

Hope this will help !!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top