/// <summary>
        /// Adds the grid columns.
        /// </summary>
        /// <param name="dataTable">The data table.</param>
        private void AddGridColumns(Grid grid, DataTable dataTable)
        {
            bool showColumns     = GetAttributeValue("ShowColumns").AsBoolean();
            var  columnList      = GetAttributeValue("Columns").SplitDelimitedValues().ToList();
            var  encryptedFields = GetAttributeValue("EncryptedFields").SplitDelimitedValues().ToList();

            int rowsToEval = 10;

            if (dataTable.Rows.Count < 10)
            {
                rowsToEval = dataTable.Rows.Count;
            }

            grid.Columns.Clear();

            if (!string.IsNullOrWhiteSpace(grid.PersonIdField))
            {
                grid.Columns.Add(new SelectField());
            }

            GridFilterColumnLookup = new Dictionary <Control, string>();

            foreach (DataColumn dataTableColumn in dataTable.Columns)
            {
                if (columnList.Count > 0 &&
                    ((showColumns && !columnList.Contains(dataTableColumn.ColumnName, StringComparer.OrdinalIgnoreCase)) ||
                     (!showColumns && columnList.Contains(dataTableColumn.ColumnName, StringComparer.OrdinalIgnoreCase))))
                {
                    continue;
                }

                BoundField bf            = new BoundField();
                var        splitCaseName = dataTableColumn.ColumnName.SplitCase();

                if (dataTableColumn.DataType == typeof(bool))
                {
                    bf = new BoolField();

                    if (GridFilter != null)
                    {
                        var id = "ddl" + dataTableColumn.ColumnName.RemoveSpecialCharacters();

                        var filterControl = new RockDropDownList()
                        {
                            Label = splitCaseName,
                            ID    = id
                        };

                        GridFilterColumnLookup.Add(filterControl, dataTableColumn.ColumnName);

                        filterControl.Items.Add(BoolToString(null));
                        filterControl.Items.Add(BoolToString(true));
                        filterControl.Items.Add(BoolToString(false));
                        GridFilter.Controls.Add(filterControl);

                        var value = GridFilter.GetUserPreference(id);

                        if (value != null)
                        {
                            filterControl.SetValue(value);
                        }
                    }
                }
                else if (dataTableColumn.DataType == typeof(DateTime))
                {
                    bf = new DateField();

                    for (int i = 0; i < rowsToEval; i++)
                    {
                        object dateObj = dataTable.Rows[i][dataTableColumn];
                        if (dateObj is DateTime)
                        {
                            DateTime dateTime = ( DateTime )dateObj;
                            if (dateTime.TimeOfDay.Seconds != 0)
                            {
                                bf = new DateTimeField();
                                break;
                            }
                        }
                    }

                    if (GridFilter != null)
                    {
                        var id = "drp" + dataTableColumn.ColumnName.RemoveSpecialCharacters();

                        var filterControl = new DateRangePicker()
                        {
                            Label = splitCaseName,
                            ID    = id,
                        };

                        GridFilterColumnLookup.Add(filterControl, dataTableColumn.ColumnName);

                        GridFilter.Controls.Add(filterControl);

                        var value = GridFilter.GetUserPreference(id);

                        if (value != null)
                        {
                            DateTime upper;
                            DateTime lower;

                            if (DateRangePicker.TryParse(value, out lower, out upper))
                            {
                                filterControl.LowerValue = lower;
                                filterControl.UpperValue = upper;
                            }
                        }
                    }
                }
                else
                {
                    if (encryptedFields.Contains(dataTableColumn.ColumnName))
                    {
                        bf = new EncryptedField();
                    }

                    bf.HtmlEncode = false;

                    if (GridFilter != null)
                    {
                        var id            = "tb" + dataTableColumn.ColumnName.RemoveSpecialCharacters();
                        var filterControl = new RockTextBox()
                        {
                            Label = splitCaseName,
                            ID    = id
                        };

                        GridFilterColumnLookup.Add(filterControl, dataTableColumn.ColumnName);

                        GridFilter.Controls.Add(filterControl);
                        var key   = filterControl.ID;
                        var value = GridFilter.GetUserPreference(key);

                        if (value != null)
                        {
                            filterControl.Text = value;
                        }
                    }
                }

                bf.DataField      = dataTableColumn.ColumnName;
                bf.SortExpression = dataTableColumn.ColumnName;
                bf.HeaderText     = splitCaseName;
                grid.Columns.Add(bf);
            }
        }