using System.Collections.Generic;
using System.Threading.Tasks;
namespace SmartVideoLibrary
public static int stc_displayPageButtonCount = 6;
public delegate string PageButtonUrlStringFormatMethod(int pageIndex);
PageButtonUrlStringFormatMethod func
_currentPageIndx = currentPageIndx;
_totalRowCount= totalRowCount;
_maxPageIndex = totalRowCount / _pageSize + 1;
_lastPageBlockIndex = totalRowCount / (stc_displayPageButtonCount * _pageSize) + 1;
_pageBlockIndex = ((_currentPageIndx -1) / stc_displayPageButtonCount) + 1;
_startPageIndex = (_pageBlockIndex - 1) * stc_displayPageButtonCount + 1;
_endPageIndex = (_startPageIndex + stc_displayPageButtonCount -1) < _maxPageIndex ? (_startPageIndex + stc_displayPageButtonCount - 1) : _maxPageIndex;
_isDisplayPrevBtn = _pageBlockIndex != 1;
_isDisplayNextBtn = _pageBlockIndex != _lastPageBlockIndex;
string html = string.Empty;
html += "<nav class=\"clearfix text-center\"><ul class=\"pagination\">";
html += string.Format("<li><a href=\"{0}\"><<</a></li>", _func(_startPageIndex-1), _startPageIndex -1);
for(int i = _startPageIndex; i <= _endPageIndex; i++)
if(i != _currentPageIndx)
html += string.Format("<li><a href=\"{0}\">{1}</a></li>", _func(i), i);
html += string.Format("<li><a class=\"active\" href =\"{0}\">{1}</a></li>", _func(i), i);
html += string.Format("<li><a href=\"{0}\">>></a></li>", _func(_endPageIndex+1), _endPageIndex+1);
private int _maxPageIndex;
private int _pageBlockIndex;
PageButtonUrlStringFormatMethod _func;
private int _startPageIndex;
private int _endPageIndex;
private bool _isDisplayPrevBtn;
private bool _isDisplayNextBtn;
private int _lastPageBlockIndex;