public static void SaveGridSettings(Telerik.Web.UI.RadGrid gridInstance, eGrid grid, string userName) { var masterTable = gridInstance.MasterTableView; var groupByExpressions = masterTable.GroupByExpressions.Cast <GridGroupByExpression>(); var allColumns = masterTable.Columns.Cast <GridColumn>().Concat(masterTable.AutoGeneratedColumns); var losFormatter = new LosFormatter(); var serializeViewState = new Func <IStateManager, string>(sm => { using (var writer = new StringWriter()) { losFormatter.Serialize(writer, sm.SaveViewState()); return(writer.ToString()); } }); var gridState = new GridState { GroupByExpressionViewStates = groupByExpressions.Select(gbe => serializeViewState(gbe)), SortExpressionsViewState = serializeViewState(masterTable.SortExpressions), FilterExpression = masterTable.FilterExpression, ColumnStates = allColumns.ToDictionary( c => c.UniqueName, c => new GridColumnState { Visible = c.Visible, Width = c.HeaderStyle.Width, OrderIndex = c.OrderIndex }), }; Orchestrator.DataAccess.SystemSettings.SaveGridSettings(userName, (int)grid, gridState.Serialize(), null); }