/// <summary> /// Populates the tag list. /// </summary> private void PopulateTagList() { int entityTypePersonId = EntityTypeCache.GetId( typeof( Rock.Model.Person ) ) ?? 0; var tagQry = new TagService( new RockContext() ).Queryable( "OwnerPersonAlias" ).Where( a => a.EntityTypeId == entityTypePersonId ); RockPage rockPage = _rblTagType.Page as RockPage; if ( _rblTagType.SelectedValueAsInt() == 1 ) { // Personal tags - tags where the ownerid is the current person id tagQry = tagQry.Where( a => a.OwnerPersonAlias.PersonId == rockPage.CurrentPersonId ).OrderBy( a => a.Name ); } else { // Organizational tags - tags where the ownerid is null tagQry = tagQry.Where( a => a.OwnerPersonAlias == null ).OrderBy( a => a.Name ); } _ddlTagList.Items.Clear(); var tempTagList = tagQry.ToList(); foreach ( var tag in tagQry.Select( a => new { a.Guid, a.Name } ) ) { _ddlTagList.Items.Add( new ListItem( tag.Name, tag.Guid.ToString() ) ); } }