0
votes

I'm creating a column through ItemTemplate in my gridview, how can i adjust it to be my last column, unfortunately .net is making this column to be the first in grid view i want it to be the last column. The rest of the columns are automatically created by this code.

I mean

gridview1.datasource = myArrayList
gridview1.databind()

Please help me

Thanks in anticipation

1

1 Answers

1
votes

Don't use the auto generation feature (AutoGenerateColumns="false") and supply the columns in the <columns> collection of the grid, or use LINQ:

var list = new List<MyClass>
{
   new MyClass { Name = "A", Value = 1, Key = 1 }
};

gridView1.datasource = list.Select(i => new
{
    i.Key,
    i.Name,
    i.Value
});

THe first option will be better on performance.