/// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            if (Person != null)
            {
                var familyIds = families.Select( f => f.Key ).ToList();
                var qry = new HistoryService( new RockContext() ).Queryable( "CreatedByPersonAlias.Person" )
                    .Where( h =>
                        ( h.EntityTypeId == personEntityTypeId && h.EntityId == Person.Id ) ||
                        ( h.EntityTypeId == groupEntityTypeId && familyIds.Contains( h.EntityId ) ) );

                int categoryId = int.MinValue;
                if (int.TryParse(gfSettings.GetUserPreference("Category"), out categoryId))
                {
                    qry = qry.Where( h => h.CategoryId == categoryId);
                }

                string summary = gfSettings.GetUserPreference("Summary Contains");
                if (!string.IsNullOrWhiteSpace(summary))
                {
                    qry = qry.Where( h => h.Summary.Contains( summary ) );
                }

                int personId = int.MinValue;
                if ( int.TryParse( gfSettings.GetUserPreference( "Who" ), out personId ) )
                {
                    qry = qry.Where( h => h.CreatedByPersonAlias.PersonId == personId );
                }

                var drp = new DateRangePicker();
                drp.DelimitedValues = gfSettings.GetUserPreference( "Date Range" );
                if ( drp.LowerValue.HasValue )
                {
                    qry = qry.Where( h => h.CreatedDateTime >= drp.LowerValue.Value );
                }
                if ( drp.UpperValue.HasValue )
                {
                    DateTime upperDate = drp.UpperValue.Value.Date.AddDays( 1 );
                    qry = qry.Where( h => h.CreatedDateTime < upperDate );
                }

                SortProperty sortProperty = gHistory.SortProperty;
                if ( sortProperty != null )
                {
                    qry = qry.Sort( sortProperty );
                }
                else
                {
                    qry = qry.OrderByDescending( t => t.CreatedDateTime );
                }

                // Combine history records that were saved at the same time
                var histories = new List<History>();
                foreach(var history in qry)
                {
                    var existingHistory = histories
                        .Where( h =>
                            h.CreatedByPersonAliasId == history.CreatedByPersonAliasId &&
                            h.CreatedDateTime == history.CreatedDateTime &&
                            h.EntityTypeId == history.EntityTypeId &&
                            h.EntityId == history.EntityId &&
                            h.CategoryId == history.CategoryId &&
                            h.RelatedEntityTypeId == history.RelatedEntityTypeId &&
                            h.RelatedEntityId == history.RelatedEntityId ).FirstOrDefault();
                    if (existingHistory != null)
                    {
                        existingHistory.Summary += "<br/>" + history.Summary;
                    }
                    else
                    {
                        histories.Add(history);
                    }
                }

                gHistory.DataSource = histories.Select( h => new
                {
                    Id = h.Id,
                    CategoryId = h.CategoryId,
                    Category = h.Category != null ? h.Category.Name : "",
                    EntityTypeId = h.EntityTypeId,
                    EntityId = h.EntityId,
                    Caption = h.Caption ?? string.Empty,
                    Summary = h.Summary,
                    RelatedEntityTypeId = h.RelatedEntityTypeId ?? 0,
                    RelatedEntityId = h.RelatedEntityId ?? 0,
                    CreatedByPersonId = h.CreatedByPersonAlias != null ? h.CreatedByPersonAlias.PersonId : 0,
                    PersonName = h.CreatedByPersonAlias != null && h.CreatedByPersonAlias.Person != null ? h.CreatedByPersonAlias.Person.NickName + " " + h.CreatedByPersonAlias.Person.LastName : "",
                    CreatedDateTime = h.CreatedDateTime
                } ).ToList();
                gHistory.DataBind();
            }
        }