How can I change gridview templatecolumn order dynamically?
Iterate through all columns of the GridView object and Store them in a collection.
List<DataControlField> columns = new List<DataControlField>();
foreach (DataControlField column in gv.Columns)
{
columns.Add(column);
}
Rearrange the column-objects as you want in the collection.
//Rearrange columns' collection..
Clear all columns of the GridView object and add columns from the collection to GridView object.
gv.Columns.Clear();
foreach (DataControlField column in columns)
{
gv.Columns.Add(column);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With