public void ApplyColumnFormat(GridViewColumn gvCol, OlapColumnInfo fInfo) { var col = gvCol as GridViewDataColumn; if (col == null) { return; } col.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; col.Caption = fInfo.Caption; col.PropertiesEdit.DisplayFormatString = fInfo.Format.FormatString; switch (fInfo.Format.FormatType) { case FormatType.DateTime: col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; break; case FormatType.Numeric: col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right; break; default: col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left; break; } if (fInfo.Caption.ToLower().Equals("year") || fInfo.Caption.ToLower().Equals("month") || fInfo.Caption.ToLower().Equals("date")) { col.Width = 50; col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; return; } col.Width = fInfo.ColWidth; }
public void ApplyColumnFormat(GridViewColumn gvCol, OlapColumnInfo fInfo) { var col = gvCol as GridViewDataColumn; if (col == null) return; col.HeaderStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; col.Caption = fInfo.Caption; col.PropertiesEdit.DisplayFormatString = fInfo.Format.FormatString; switch (fInfo.Format.FormatType) { case FormatType.DateTime: col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; break; case FormatType.Numeric: col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right; break; default: col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Left; break; } if (fInfo.Caption.ToLower().Equals("year") || fInfo.Caption.ToLower().Equals("month") || fInfo.Caption.ToLower().Equals("date")) { col.Width = 50; col.CellStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center; return; } col.Width = fInfo.ColWidth; }