I have a RadGrid where I am auto generating columns because they can changed depending on the source. And I want to display only certain columns and in a specific order. Its easiest for me to store the columns to display in a comma delimited string. I created the code below to try to do this. However it fails because in the Page_Load method the grid.MasterTableView.Columns is always empty, even though I do a DataBind first. Any idea how I can get this to work?
Thanks,
Jason
Thanks,
Jason
protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { // bind grid.MasterTableView.DataBind(); grid.DataBind(); // columns var cols = grid.MasterTableView.Columns; foreach (GridColumn c in cols) { c.Visible = false; } // fieldNames is a comma delimited list of column names in the correct order var fields = fieldNames.Split(new char[',']); for (var j = 0; j < fields.Length; j++) { var c = cols.FindByUniqueNameSafe(fields[j]); if (c != null) { c.Visible = true; c.OrderIndex = j; } } }}