开发者

customizing the auto generated grid view in asp.net/c#

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 he开发者_运维问答lp me

Thanks in anticipation


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜