本文整理汇总了C#中Pagination.GetCurrentPageItems方法的典型用法代码示例。如果您正苦于以下问题:C# Pagination.GetCurrentPageItems方法的具体用法?C# Pagination.GetCurrentPageItems怎么用?C# Pagination.GetCurrentPageItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagination
的用法示例。
在下文中一共展示了Pagination.GetCurrentPageItems方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowView
/// <summary>
/// Binds the grid.
/// </summary>
private void ShowView()
{
nbContentError.Visible = false;
upnlContent.Update();
var pageRef = CurrentPageReference;
pageRef.Parameters.AddOrReplace( "Page", "PageNum" );
Dictionary<string, object> linkedPages = new Dictionary<string, object>();
linkedPages.Add( "DetailPage", LinkedPageRoute( "DetailPage" ) );
var errorMessages = new List<string>();
List<ContentChannelItem> content;
try
{
content = GetContent( errorMessages ) ?? new List<ContentChannelItem>();
}
catch (Exception ex)
{
this.LogException( ex );
Exception exception = ex;
while ( exception != null )
{
errorMessages.Add( exception.Message );
exception = exception.InnerException;
}
content = new List<ContentChannelItem>();
}
if (errorMessages.Any())
{
nbContentError.Text = "ERROR: There was a problem getting content...<br/> ";
nbContentError.NotificationBoxType = NotificationBoxType.Danger;
nbContentError.Details = errorMessages.AsDelimited( "<br/>" );
nbContentError.Visible = true;
}
var pagination = new Pagination();
pagination.ItemCount = content.Count();
pagination.PageSize = GetAttributeValue( "Count" ).AsInteger();
pagination.CurrentPage = PageParameter( "Page" ).AsIntegerOrNull() ?? 1;
pagination.UrlTemplate = pageRef.BuildUrl();
var currentPageContent = pagination.GetCurrentPageItems( content );
var commonMergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson );
// Merge content and attribute fields if block is configured to do so.
if ( GetAttributeValue( "MergeContent" ).AsBoolean() )
{
var itemMergeFields = new Dictionary<string, object>();
if ( CurrentPerson != null )
{
// TODO: When support for "Person" is not supported anymore (should use "CurrentPerson" instead), remove this line
itemMergeFields.Add( "Person", CurrentPerson );
}
commonMergeFields.ToList().ForEach( d => itemMergeFields.Add( d.Key, d.Value ) );
foreach ( var item in currentPageContent )
{
itemMergeFields.AddOrReplace( "Item", item );
var enabledCommands = GetAttributeValue( "EnabledLavaCommands" );
item.Content = item.Content.ResolveMergeFields( itemMergeFields, enabledCommands );
foreach ( var attributeValue in item.AttributeValues )
{
attributeValue.Value.Value = attributeValue.Value.Value.ResolveMergeFields( itemMergeFields, enabledCommands );
}
}
}
var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( this.RockPage, this.CurrentPerson );
mergeFields.Add( "Pagination", pagination );
mergeFields.Add( "LinkedPages", linkedPages );
mergeFields.Add( "Items", currentPageContent );
mergeFields.Add( "RockVersion", Rock.VersionInfo.VersionInfo.GetRockProductVersionNumber() );
// enable showing debug info
if ( GetAttributeValue( "EnableDebug" ).AsBoolean() && IsUserAuthorized( Authorization.EDIT ) )
{
mergeFields["Items"] = currentPageContent.Take( 5 ).ToList();
lDebug.Visible = true;
lDebug.Text = mergeFields.lavaDebugInfo();
mergeFields["Items"] = currentPageContent;
}
else
{
lDebug.Visible = false;
lDebug.Text = string.Empty;
}
// TODO: When support for "Person" is not supported anymore (should use "CurrentPerson" instead), remove this line
mergeFields.AddOrIgnore( "Person", CurrentPerson );
//.........这里部分代码省略.........