public override void HandleEvent(CommandEventArgs e) { string commandName = e.CommandName; int newStartIndex = -1; int pageSize = DataPager.PageSize; if (String.Compare(commandName, DataControlCommands.NextPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0) { newStartIndex = _startRowIndex + pageSize; if (newStartIndex > _totalRowCount) { newStartIndex = _totalRowCount - pageSize; } } else if (String.Compare(commandName, DataControlCommands.PreviousPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0) { newStartIndex = _startRowIndex - pageSize; if (newStartIndex < 0) { newStartIndex = 0; } } else { newStartIndex = (Int32.Parse(commandName) - 1) * pageSize; } if (newStartIndex != -1) { DataPager.SetPageProperties(newStartIndex, pageSize, true); } }
public override void HandleEvent(CommandEventArgs e) { if (String.IsNullOrEmpty(DataPager.QueryStringField)) { if (String.Equals(e.CommandName, DataControlCommands.PreviousPageCommandArgument)) { int newStartRowIndex = _startRowIndex - DataPager.PageSize; if (newStartRowIndex < 0) { newStartRowIndex = 0; } DataPager.SetPageProperties(newStartRowIndex, DataPager.PageSize, true); } else if (String.Equals(e.CommandName, DataControlCommands.NextPageCommandArgument)) { int newStartRowIndex = _startRowIndex + DataPager.PageSize; if (newStartRowIndex > _totalRowCount) { newStartRowIndex = _totalRowCount - DataPager.PageSize; } DataPager.SetPageProperties(newStartRowIndex, DataPager.PageSize, true); } else if (String.Equals(e.CommandName, DataControlCommands.FirstPageCommandArgument)) { DataPager.SetPageProperties(0, DataPager.PageSize, true); } else if (String.Equals(e.CommandName, DataControlCommands.LastPageCommandArgument)) { int newStartRowIndex; int recordsOnLastPage = _totalRowCount % DataPager.PageSize; if (recordsOnLastPage == 0) { newStartRowIndex = _totalRowCount - DataPager.PageSize; } else { newStartRowIndex = _totalRowCount - recordsOnLastPage; } DataPager.SetPageProperties(newStartRowIndex, DataPager.PageSize, true); } } }
public override void HandleEvent(CommandEventArgs e) { DataPagerFieldItem item = null; DataPagerFieldCommandEventArgs cea = e as DataPagerFieldCommandEventArgs; if (cea != null) { item = cea.Item; } DataPagerCommandEventArgs pagerEventArgs = new DataPagerCommandEventArgs(this, _totalRowCount, e, item); OnPagerCommand(pagerEventArgs); if (pagerEventArgs.NewStartRowIndex != -1) { DataPager.SetPageProperties(pagerEventArgs.NewStartRowIndex, pagerEventArgs.NewMaximumRows, true); } }
public override void HandleEvent(CommandEventArgs e) { if (String.IsNullOrEmpty(DataPager.QueryStringField)) { int newStartRowIndex = -1; int currentPageIndex = _startRowIndex / DataPager.PageSize; int firstButtonIndex = (_startRowIndex / (ButtonCount * DataPager.PageSize)) * ButtonCount; int lastButtonIndex = firstButtonIndex + ButtonCount - 1; int lastRecordIndex = ((lastButtonIndex + 1) * DataPager.PageSize) - 1; if (String.Equals(e.CommandName, DataControlCommands.PreviousPageCommandArgument)) { newStartRowIndex = (firstButtonIndex - 1) * DataPager.PageSize; if (newStartRowIndex < 0) { newStartRowIndex = 0; } } else if (String.Equals(e.CommandName, DataControlCommands.NextPageCommandArgument)) { newStartRowIndex = lastRecordIndex + 1; if (newStartRowIndex > _totalRowCount) { newStartRowIndex = _totalRowCount - DataPager.PageSize; } } else { int pageIndex = Convert.ToInt32(e.CommandName, CultureInfo.InvariantCulture); newStartRowIndex = pageIndex * DataPager.PageSize; } if (newStartRowIndex != -1) { DataPager.SetPageProperties(newStartRowIndex, DataPager.PageSize, true); } } }
public override void HandleEvent(CommandEventArgs e) { var args = e as DataPagerCommandEventArgs; if (args == null) { return; } DataPager pager = DataPager; var eventArgs = new DataPagerCommandEventArgs(this, pager.TotalRowCount, e, args.Item); OnPagerCommand(eventArgs); int newStartRowIndex = eventArgs.NewStartRowIndex; if (newStartRowIndex < 0) { return; } pager.SetPageProperties(newStartRowIndex, eventArgs.NewMaximumRows, true); }
public override void HandleEvent(CommandEventArgs e) { string commandName = e.CommandName; int pageNum; if (!Int32.TryParse(e.CommandArgument as string, out pageNum)) { pageNum = 0; } else if (pageNum >= 1) { pageNum--; } else if (pageNum < 0) { pageNum = 0; } int newStartIndex = -1; int pageSize = DataPager.PageSize; int offset = pageSize * pageNum; if (String.Compare(commandName, DataControlCommands.NextPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(commandName, DataControlCommands.PreviousPageCommandArgument, StringComparison.OrdinalIgnoreCase) == 0) { newStartIndex = offset; } else { newStartIndex = (Int32.Parse(commandName) - 1) * pageSize; } if (newStartIndex != -1) { DataPager.SetPageProperties(newStartIndex, pageSize, true); } }
public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { _startRowIndex = startRowIndex; _maximumRows = maximumRows; _totalRowCount = totalRowCount; _fieldIndex = fieldIndex; bool setPagePropertiesNeeded = false; bool queryMode = GetQueryModeStartRowIndex(_totalRowCount, _maximumRows, ref _startRowIndex, ref setPagePropertiesNeeded); bool addNonBreakingSpace = RenderNonBreakingSpacesBetweenControls; int buttonCount = ButtonCount; int totalPages = totalRowCount / maximumRows + (totalRowCount % maximumRows > 0 ? 1 : 0); int currentPage = startRowIndex == 0 ? 1 : (startRowIndex / maximumRows) + 1; int activePage = ((startRowIndex / (maximumRows * buttonCount)) * buttonCount) + 1; int lastPage = activePage + buttonCount - 1; bool showPreviousPage = activePage > buttonCount; bool showNextPage = totalPages - activePage >= buttonCount; if (lastPage > totalPages) { lastPage = totalPages; } int newPageNum; if (showPreviousPage) { newPageNum = activePage - 1; if (newPageNum < 1) { newPageNum = 1; } CreateButton(container, DataControlCommands.PreviousPageCommandArgument, PreviousPageText, PreviousPageImageUrl, NextPreviousButtonCssClass, newPageNum, queryMode, true, addNonBreakingSpace, false); } string numericButtonCssClass = NumericButtonCssClass; bool enabled; string pageString; while (activePage <= lastPage) { enabled = activePage != currentPage; pageString = activePage.ToString(CultureInfo.InvariantCulture); CreateButton(container, pageString, pageString, String.Empty, enabled ? numericButtonCssClass : CurrentPageLabelCssClass, activePage, queryMode, enabled, addNonBreakingSpace, true); activePage++; } if (showNextPage && addNonBreakingSpace) { container.Controls.Add(new LiteralControl(" ")); } if (showNextPage) { CreateButton(container, DataControlCommands.NextPageCommandArgument, NextPageText, NextPageImageUrl, NextPreviousButtonCssClass, activePage, queryMode, true, addNonBreakingSpace, false); } if (setPagePropertiesNeeded) { DataPager.SetPageProperties(_startRowIndex, _maximumRows, true); } }
// What's the fieldIndex used for? public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { _startRowIndex = startRowIndex; _maximumRows = maximumRows; _totalRowCount = totalRowCount; _fieldIndex = fieldIndex; bool setPagePropertiesNeeded = false; bool queryMode = GetQueryModeStartRowIndex(_totalRowCount, _maximumRows, ref _startRowIndex, ref setPagePropertiesNeeded); bool enablePrevFirst = _startRowIndex >= _maximumRows; bool enableNextLast = (_startRowIndex + _maximumRows) < _totalRowCount; bool addNonBreakingSpace = RenderNonBreakingSpacesBetweenControls; if (ShowFirstPageButton) { CreateButton(container, DataControlCommands.FirstPageCommandArgument, FirstPageText, FirstPageImageUrl, 0, queryMode, enablePrevFirst, addNonBreakingSpace); } int newPageNum = -1; if (ShowPreviousPageButton) { if (queryMode) { newPageNum = (_startRowIndex / _maximumRows) - 1; } CreateButton(container, DataControlCommands.PreviousPageCommandArgument, PreviousPageText, PreviousPageImageUrl, newPageNum, queryMode, enablePrevFirst, addNonBreakingSpace); } if (ShowNextPageButton) { if (queryMode) { newPageNum = (_startRowIndex + _maximumRows) / _maximumRows; } CreateButton(container, DataControlCommands.NextPageCommandArgument, NextPageText, NextPageImageUrl, newPageNum, queryMode, enableNextLast, addNonBreakingSpace); } if (ShowLastPageButton) { if (queryMode) { newPageNum = _totalRowCount / _maximumRows; if ((_totalRowCount % _maximumRows) == 0) { newPageNum--; } } CreateButton(container, DataControlCommands.LastPageCommandArgument, LastPageText, LastPageImageUrl, newPageNum, queryMode, enableNextLast, addNonBreakingSpace); } if (setPagePropertiesNeeded) { DataPager.SetPageProperties(_startRowIndex, _maximumRows, true); } }