protected void InsertForecastColumns(ShipmentsDueQuery qry) { // Insert columns for each forecast period GroupField grpFld; ForecastPeriodTemplate tmpl; int keyGroup = 0; for(int i = qry.PeriodTemplates.Count - 1; i >= 0; i--) { tmpl = qry.PeriodTemplates[i]; // Create the group field grpFld = new GroupField(); grpFld.Key = tmpl.Title.Replace(" ", ""); grpFld.Header.Text = tmpl.Title; wgShipmentsDue.Columns.Insert(FIRST_FORECAST_COL, grpFld); // Add the indivdual columns keyGroup = i + 1; InsertForecastColumn(string.Format("PlannedQty{0}", keyGroup), string.Format("{0} Planned Qty", tmpl.Title), grpFld); InsertForecastColumn(string.Format("PlannedSales{0}", keyGroup), string.Format("{0} Planned $$", tmpl.Title), grpFld); InsertForecastColumn(string.Format("ActualQty{0}", keyGroup), string.Format("{0} Actual Qty", tmpl.Title), grpFld); InsertForecastColumn(string.Format("ActualSales{0}", keyGroup), string.Format("{0} Actual $$", tmpl.Title), grpFld); } } protected void InsertForecastColumn(string colKey, string colHeading, GroupField grpFld) { BoundDataField newColumn = new BoundDataField(true); newColumn.Key = colKey; newColumn.Header.Text = colHeading; newColumn.DataFieldName = colKey; newColumn.DataType = "System.Decimal"; newColumn.Width = new Unit(60, UnitType.Pixel); newColumn.Header.CssClass = "gridHeadingCenter"; newColumn.CssClass = "gridCenter"; grpFld.Columns.Add(newColumn); }