How can I change gridview templatecolumn order dynamically?
A:
Iterate through all coloumns of the GridView object and Store them in a collection.
List<DataControlField> coloumns = new List<DataControlField>(); foreach (DataControlField coloumn in gv.Columns) { coloumns.Add(coloumn); }
Rearrange the coloumn-objects as you want in the collection.
//Rearrange coloumns' collection..
Clear all coloumns of the GridView object and add coloumns from the collection to GridView object.
gv.Columns.Clear(); foreach (DataControlField coloumn in coloumns) { gv.Columns.Add(coloumn); }
this. __curious_geek
2010-01-06 08:34:33
http://geekswithblogs.net/dotNETvinz/archive/2009/06/03/move--autogenerate-columns-at-leftmost-part-of-the-gridview.aspx
hotcoder
2010-01-07 05:07:31