Example #1
0
        public static void SetHeaderStyle(
            StateBag viewState,
            DataControlFieldCollection columns,
            string AscendingClassName,
            string DescendingClassName)
        {
            SortDirection sortDirection = SortDirection.Ascending;

            if (viewState[Const.SortDirection] != null)
            {
                sortDirection = (SortDirection)viewState[Const.SortDirection];
            }

            var column = viewState[Const.SortExpression] as string;

            if (typeof(BoundField) == columns.GetType())
            {
                foreach (BoundField field in columns)
                {
                    if (field.DataField == column)
                    {
                        field.HeaderStyle.CssClass = sortDirection == SortDirection.Ascending ? AscendingClassName : DescendingClassName;
                    }
                    else
                    {
                        field.HeaderStyle.CssClass = string.Empty;
                    }
                }
            }
        }