private List <int> hideCols(bool visible) { System.Collections.ObjectModel.ReadOnlyCollection <MetaColumn> cols = GridView1.GetMetaTable().Columns; List <int> mylist = new List <int>(); GridViewRow gr = GridView1.HeaderRow; if (gr == null) { return(null); } MetaTable mt = GridView1.GetMetaTable(); if (!table.IsReadOnly) { mylist.Add(0); } for (int i = 1; i < gr.Cells.Count; i++) { string coltype = "TemplateField"; string colname = ((DataControlFieldHeaderCell)gr.Cells[i]).ContainingField.ToString(); if (colname != coltype) { coltype = GridView1.GetMetaTable().GetColumn(colname).TypeCode.ToString(); switch (coltype.ToString()) { case "Object": mylist.Add(i); break; } } } return(mylist); }