Rock.Model.BlockService.GetByLayout C# (CSharp) Method

GetByLayout() public method

Returns an enumerable collection of Rock.Model.Block">Blocks that are implemented as part of a
public GetByLayout ( int layoutId ) : IQueryable
layoutId int An representing the Id of the that the block belongs to.
return IQueryable
        public IQueryable<Block> GetByLayout( int layoutId )
        {
            return Queryable()
                .Where( t => t.LayoutId == layoutId )
                .OrderBy( t => t.Zone ).ThenBy( t => t.Order );
        }

Usage Example

        /// <summary>
        /// Binds the group members grid.
        /// </summary>
        protected void BindLayoutBlocksGrid()
        {
            pnlBlocks.Visible = false;

            int layoutId = PageParameter( "layoutId" ).AsInteger();
            if ( layoutId == 0 )
            {
                pnlContent.Visible = false;
                return;
            }

            var rockContext = new RockContext();
            var layout = LayoutCache.Read( layoutId, rockContext );
            if (layout == null)
            {
                pnlContent.Visible = false;
                return;
            }

            hfLayoutId.SetValue( layoutId );

            pnlBlocks.Visible = true;

            BlockService blockService = new BlockService( new RockContext() );

            gLayoutBlocks.DataSource = blockService.GetByLayout( layoutId ).ToList();
            gLayoutBlocks.DataBind();
        }
All Usage Examples Of Rock.Model.BlockService::GetByLayout