protected void ApplyLayout(int layoutIndex, ASPxGridView grid)
    {
        if (grid != null)
        {
            grid.BeginUpdate();
            try
            {
                grid.ClearSort();
                switch (layoutIndex)
                {
                case 0:
                    grid.GroupBy(grid.Columns["ItemType"]);
                    break;

                case 1:
                    grid.GroupBy(grid.Columns["ItemType"]);
                    grid.GroupBy(grid.Columns["ItemName"]);
                    break;

                case 2:
                    grid.GroupBy(grid.Columns["ItemQty"]);
                    break;
                }
            }
            finally
            {
                grid.EndUpdate();
            }
            grid.ExpandAll();
        }
    }