/// <summary> /// Creates the page size control. /// </summary> /// <param name="container">The container.</param> private void CreatePageSizeControl(DataPagerFieldItem container) { container.Controls.Add(new LiteralControl("Show rows: ")); ButtonDropDownList pageSizeDropDownList = new ButtonDropDownList(); pageSizeDropDownList.CommandName = "UpdatePageSize"; pageSizeDropDownList.Items.Add(new ListItem("10", "10")); pageSizeDropDownList.Items.Add(new ListItem("25", "25")); pageSizeDropDownList.Items.Add(new ListItem("50", "50")); pageSizeDropDownList.Items.Add(new ListItem("100", "100")); pageSizeDropDownList.Items.Add(new ListItem("250", "250")); pageSizeDropDownList.Items.Add(new ListItem("500", "500")); ListItem pageSizeItem = pageSizeDropDownList.Items.FindByValue(base.DataPager.PageSize.ToString()); if (pageSizeItem == null) { pageSizeItem = new ListItem(base.DataPager.PageSize.ToString(), base.DataPager.PageSize.ToString()); pageSizeDropDownList.Items.Insert(0, pageSizeItem); } pageSizeItem.Selected = true; container.Controls.Add(pageSizeDropDownList); this.AddNonBreakingSpace(container); this.AddNonBreakingSpace(container); }
private void AddNonBreakingSpace(DataPagerFieldItem container) { if (RenderNonBreakingSpacesBetweenControls) { container.Controls.Add(new LiteralControl(" ")); } }
public void InstantiateIn(Control container) { DataPagerFieldItem caller = (DataPagerFieldItem)container; DataPagerDDL pager = (DataPagerDDL)caller.Parent; int totalPages = pager.TotalRowCount / pager.MaximumRows; if (pager.TotalRowCount % pager.MaximumRows > 0) { totalPages += 1; } int currentPage = (pager.StartRowIndex / pager.MaximumRows) + 1; DropDownList cmbPage = new DropDownList(); cmbPage.ID = "cmbPage"; cmbPage.AutoPostBack = true; cmbPage.SelectedIndexChanged += pager.cmbPage_SelectedIndexChanged; for (int i = 1; i <= totalPages; i++) { ListItem item = new ListItem(i.ToString(), i.ToString()); if (i == currentPage) { item.Selected = true; } cmbPage.Items.Add(item); } container.Controls.Add(new LiteralControl("Page ")); container.Controls.Add(cmbPage); container.Controls.Add(new LiteralControl(" of " + totalPages + " pages | ")); }
public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { HtmlGenericControl ul = new HtmlGenericControl("ul"); ul.Attributes["class"] = "clearfix"; int num = startRowIndex / maximumRows; int num2 = (startRowIndex / (this.ButtonCount * maximumRows)) * this.ButtonCount; int num3 = (num2 + this.ButtonCount) - 1; int num4 = ((num3 + 1) * maximumRows) - 1; for (int i = 0; (i < this.ButtonCount) && (totalRowCount > ((i + num2) * maximumRows)); i++) { HtmlGenericControl li = new HtmlGenericControl("li"); if ((i + num2) == num) { Label child = new Label(); child.Text = ((i + num2) + 1).ToString(CultureInfo.InvariantCulture); if (!string.IsNullOrEmpty(this.CurrentPageLabelCssClass)) { child.CssClass = this.CurrentPageLabelCssClass; } li.Controls.Add(child); } else { int num7 = (i + num2) + 1; int num8 = i + num2; li.Controls.Add(string.IsNullOrEmpty(base.DataPager.QueryStringField) ? CreateNumericButton(num7.ToString(CultureInfo.InvariantCulture), fieldIndex.ToString(CultureInfo.InvariantCulture), num8.ToString(CultureInfo.InvariantCulture)) : CreateNumericLink(num8)); } ul.Controls.Add(li); } container.Controls.Add(ul); }
/// <summary> /// Creates the page size control. /// </summary> /// <param name="container">The container.</param> private void CreatePageSizeControl(DataPagerFieldItem container) { var pageSizeDropDownList = new ButtonDropDownList { CommandName = "UpdatePageSize", CssClass = "form-control" }; pageSizeDropDownList.Items.Add(new ListItem("5", "5")); pageSizeDropDownList.Items.Add(new ListItem("10", "10")); pageSizeDropDownList.Items.Add(new ListItem("15", "15")); pageSizeDropDownList.Items.Add(new ListItem("25", "25")); pageSizeDropDownList.Items.Add(new ListItem("50", "50")); pageSizeDropDownList.Items.Add(new ListItem("75", "75")); pageSizeDropDownList.Items.Add(new ListItem("100", "100")); var pageSizeItem = pageSizeDropDownList.Items.FindByValue(DataPager.PageSize.ToString()); if (pageSizeItem == null) { pageSizeItem = new ListItem(DataPager.PageSize.ToString(), DataPager.PageSize.ToString()); pageSizeDropDownList.Items.Insert(0, pageSizeItem); } pageSizeItem.Selected = true; container.Controls.Add(pageSizeDropDownList); container.Controls.Add(new LiteralControl(string.Format("<span>{0}</span>", _PerPage))); }
private void CreatePageSizeControl(DataPagerFieldItem container) { container.Controls.Add(new LiteralControl("Show rows: ")); var dd = new CommandDropDownList(); dd.CommandName = "UpdatePageSize"; dd.Items.Add(new ListItem("10")); dd.Items.Add(new ListItem("25")); dd.Items.Add(new ListItem("50")); dd.Items.Add(new ListItem("75")); dd.Items.Add(new ListItem("100")); dd.Items.Add(new ListItem("200")); var pageSizeItem = dd.Items.FindByValue(base.DataPager.PageSize.ToString()); if (pageSizeItem == null) { pageSizeItem = new ListItem(DataPager.PageSize.ToString()); dd.Items.Insert(0, pageSizeItem); } pageSizeItem.Selected = true; container.Controls.Add(dd); AddNonBreakingSpace(container); AddNonBreakingSpace(container); }
/// <summary> /// The create data pagers. /// </summary> /// <param name="container"> /// The container. /// </param> /// <param name="startRowIndex"> /// The start row index. /// </param> /// <param name="maximumRows"> /// The maximum rows. /// </param> /// <param name="totalRowCount"> /// The total row count. /// </param> /// <param name="fieldIndex"> /// The field index. /// </param> public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { PageSize = (container.TemplateControl as ProductList).CategoryPageSize; base.CreateDataPagers(container, startRowIndex, PageSize, totalRowCount, fieldIndex); if (maximumRows == Int32.MaxValue) { // show all if (DataPager.Controls.Count > 2) { // find show all button and disable it disableShowAll(DataPager.Controls[0]); // recreate "1" as LinkButton createNumber1(DataPager.Controls[2], (container.TemplateControl as ProductList).Request); } } if (DataPager.Controls.Count > 2) { // hide Back button hideBackButton(DataPager.Controls[1]); } string pageNumber; if ((pageNumber = (container.TemplateControl as ProductList).Request.QueryString["ispage"]) != null) { int page = int.Parse(pageNumber); showPageNumber(DataPager.Controls[0], page); } }
private void CreateDataPagersForCommand(DataPagerFieldItem container, int fieldIndex) { int aPageSize = this._startRowIndex / this._maximumRows; int num2 = (this._startRowIndex / (this.ButtonCount * this._maximumRows)) * this.ButtonCount; int num3 = (num2 + this.ButtonCount) - 1; int num4 = ((num3 + 1) * this._maximumRows) - 1; if (num2 != 0) { container.Controls.Add(this.CreateNextPrevButton("icon-angle-left", "Prev", fieldIndex.ToString(CultureInfo.InvariantCulture))); } for (int i = 0; (i < this.ButtonCount) && (this._totalRowCount > ((i + num2) * this._maximumRows)); i++) { if (i + num2 == aPageSize) { container.Controls.Add(CreateCurrentPageLabel(i + num2)); } else { int num7 = (i + num2) + 1; int num8 = i + num2; container.Controls.Add(this.CreateNumericButton(num7.ToString(CultureInfo.InvariantCulture), fieldIndex.ToString(CultureInfo.InvariantCulture), num8.ToString(CultureInfo.InvariantCulture))); } } if (num4 < (this._totalRowCount - 1)) { container.Controls.Add(this.CreateNextPrevButton("icon-angle-right", "Next", fieldIndex.ToString(CultureInfo.InvariantCulture))); } }
/// <summary> /// Creates the data pagers for command. /// </summary> /// <param name="container">The container.</param> /// <param name="fieldIndex">Index of the field.</param> private void CreateDataPagersForCommand(DataPagerFieldItem container, int fieldIndex) { //Goto item texbox this.CreateGoToTexBox(container); //Control used to set the page size. this.CreatePageSizeControl(container); //Set of records - total records this.CreateLabelRecordControl(container); //Previous button if (this._showPreviousPage) { container.Controls.Add(this.CreateControl("Prev", this.PreviousPageText, fieldIndex, this.PreviousPageImageUrl, this._showPreviousPage)); this.AddNonBreakingSpace(container); } //Next button if (this._showNextPage) { container.Controls.Add(this.CreateControl("Next", this.NextPageText, fieldIndex, this.NextPageImageUrl, this._showNextPage)); this.AddNonBreakingSpace(container); } }
private void CreateDataPagersForCommand(DataPagerFieldItem container, int fieldIndex) { int currentPageIndex = _startRowIndex / _maximumRows; int firstButtonIndex = (_startRowIndex / (ButtonCount * _maximumRows)) * ButtonCount; int lastButtonIndex = firstButtonIndex + ButtonCount - 1; int lastRecordIndex = ((lastButtonIndex + 1) * _maximumRows) - 1; container.Controls.Add(new LiteralControl("<div class=\"grid-footer-left pull-left\">")); //Set of records - total records CreateLabelRecordControl(container); //Control used to set the page size. CreatePageSizeControl(container); container.Controls.Add(new LiteralControl("</div>")); container.Controls.Add(new LiteralControl("<ul class=\"pagination pull-right\">")); if (firstButtonIndex != 0) { container.Controls.Add(new LiteralControl("<li>")); container.Controls.Add(CreateNextPrevButton(PreviousPageText, DataControlCommands.PreviousPageCommandArgument, fieldIndex.ToString(CultureInfo.InvariantCulture), PreviousPageImageUrl)); container.Controls.Add(new LiteralControl("</li>")); } for (int i = 0; i < ButtonCount && _totalRowCount > ((i + firstButtonIndex) * _maximumRows); i++) { if (i + firstButtonIndex == currentPageIndex) { //Label pageNumber = new Label(); //pageNumber.Text = (i + firstButtonIndex + 1).ToString(CultureInfo.InvariantCulture); //if (!String.IsNullOrEmpty(CurrentPageLabelCssClass)) //{ // pageNumber.CssClass = CurrentPageLabelCssClass; //} container.Controls.Add(new LiteralControl("<li class=\"active\">")); container.Controls.Add(new LiteralControl(string.Format("<span>{0}<span class=\"sr-only\">(current)</span></span>", i + firstButtonIndex + 1))); container.Controls.Add(new LiteralControl("</li>")); } else { container.Controls.Add(new LiteralControl("<li>")); container.Controls.Add(CreateNumericButton((i + firstButtonIndex + 1).ToString(CultureInfo.InvariantCulture), fieldIndex.ToString(CultureInfo.InvariantCulture), (i + firstButtonIndex).ToString(CultureInfo.InvariantCulture))); container.Controls.Add(new LiteralControl("</li>")); } } if (lastRecordIndex < _totalRowCount - 1) { container.Controls.Add(new LiteralControl("<li>")); container.Controls.Add(CreateNextPrevButton(NextPageText, DataControlCommands.NextPageCommandArgument, fieldIndex.ToString(CultureInfo.InvariantCulture), NextPageImageUrl)); container.Controls.Add(new LiteralControl("</li>")); } container.Controls.Add(new LiteralControl("</ul>")); }
private void CreateDataPagersForCommand(DataPagerFieldItem container, int fieldIndex) { CreateLabelRecordControl(container); CreateGoToTexBox(container); CreatePageSizeControl(container); container.Controls.Add(CreateControl("Prev", PreviousPageText, fieldIndex, PreviousPageImageUrl)); AddNonBreakingSpace(container); container.Controls.Add(CreateControl("Next", NextPageText, fieldIndex, NextPageImageUrl)); }
/// <summary> /// Creates the label record control. /// </summary> /// <param name="container">The container.</param> private void CreateLabelRecordControl(DataPagerFieldItem container) { int endRowIndex = _startRowIndex + DataPager.PageSize; if (endRowIndex > _totalRowCount) { endRowIndex = _totalRowCount; } container.Controls.Add(new LiteralControl("<span>")); container.Controls.Add(new LiteralControl(string.Format(_rowXofY, _startRowIndex + 1, endRowIndex, _totalRowCount))); container.Controls.Add(new LiteralControl("</span>")); }
public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { this._startRowIndex = startRowIndex; this._maximumRows = maximumRows; this._totalRowCount = totalRowCount; if (string.IsNullOrEmpty(base.DataPager.QueryStringField)) { this.CreateDataPagersForCommand(container, fieldIndex); } else { this.CreateDataPagersForQueryString(container, fieldIndex); } }
private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex) { int pageIndex = this._startRowIndex / this._maximumRows; bool flag = false; if (!base.QueryStringHandled) { int requestPage; base.QueryStringHandled = true; if (int.TryParse(base.QueryStringValue, out requestPage)) { requestPage--; int pageCount = (this._totalRowCount - 1) / this._maximumRows; if ((requestPage >= 0) && (requestPage <= pageCount)) { pageIndex = requestPage; this._startRowIndex = pageIndex * this._maximumRows; flag = true; } } } int firstPageIndex = (this._startRowIndex / (this.ButtonCount * this._maximumRows)) * this.ButtonCount; int lastPage = (firstPageIndex + this.ButtonCount) - 1; int lastVisiblePagerRow = ((lastPage + 1) * this._maximumRows) - 1; if (firstPageIndex != 0) { container.Controls.Add(this.CreateNextPrevLink("icon-angle-left", firstPageIndex - 1)); } for (int i = 0; (i < this.ButtonCount) && (this._totalRowCount > ((i + firstPageIndex) * this._maximumRows)); i++) { if ((i + firstPageIndex) == pageIndex) { container.Controls.Add(CreateCurrentPageLabel(i + firstPageIndex)); } else { container.Controls.Add(this.CreateNumericLink(i + firstPageIndex)); } } if (lastVisiblePagerRow < (this._totalRowCount - 1)) { container.Controls.Add(this.CreateNextPrevLink("icon-angle-right", firstPageIndex + this.ButtonCount)); } if (flag) { base.DataPager.SetPageProperties(this._startRowIndex, this._maximumRows, true); } }
public override void CreateDataPagers(DataPagerFieldItem container, int startrow, int rowsperpage, int totalrows, int fieldIndex) { startRowIndex = startrow; maximumRows = rowsperpage; totalRowCount = totalrows; if (string.IsNullOrEmpty(DataPager.QueryStringField)) { CreateDataPagersForCommand(container, fieldIndex); } else { CreateDataPagersForQueryString(container, fieldIndex); } }
/// <summary> /// Creates the label record control. /// </summary> /// <param name="container">The container.</param> private void CreateLabelRecordControl(DataPagerFieldItem container) { int endRowIndex = this._startRowIndex + base.DataPager.PageSize; if (endRowIndex > this._totalRowCount) { endRowIndex = this._totalRowCount; } container.Controls.Add(new LiteralControl(string.Format("{0} - {1} of {2}", this._startRowIndex + 1, endRowIndex, this._totalRowCount))); this.AddNonBreakingSpace(container); this.AddNonBreakingSpace(container); this.AddNonBreakingSpace(container); }
private void CreateLabelRecordControl(DataPagerFieldItem container) { int endRowIndex = startRowIndex + DataPager.PageSize; if (endRowIndex > totalRowCount) { endRowIndex = totalRowCount; } container.Controls.Add(new LiteralControl("{0:N0}-{1:N0} of <b>{2:N0}</b>".Fmt(startRowIndex + 1, endRowIndex, totalRowCount))); AddNonBreakingSpace(container); AddNonBreakingSpace(container); AddNonBreakingSpace(container); }
private void CreateGoToTexBox(DataPagerFieldItem container) { var label = new Label(); label.Text = "Go to row: "; container.Controls.Add(label); var goToTextBox = new CommandTextBox(); goToTextBox.CommandName = "GoToItem"; goToTextBox.Width = new Unit("20px"); container.Controls.Add(goToTextBox); AddNonBreakingSpace(container); AddNonBreakingSpace(container); }
/// <summary> /// Creates the go to tex box. /// </summary> /// <param name="container">The container.</param> private void CreateGoToTexBox(DataPagerFieldItem container) { Label label = new Label(); label.Text = "Go to: "; container.Controls.Add(label); ButtonTextBox goToTextBox = new ButtonTextBox(); goToTextBox.CommandName = "GoToItem"; goToTextBox.Width = new Unit("20px"); container.Controls.Add(goToTextBox); this.AddNonBreakingSpace(container); this.AddNonBreakingSpace(container); }
/// <summary> /// Creates the data pagers for query string. /// </summary> /// <param name="container">The container.</param> /// <param name="fieldIndex">Index of the field.</param> private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex) { bool validPageIndex = false; if (!base.QueryStringHandled) { int num; base.QueryStringHandled = true; if (int.TryParse(base.QueryStringValue, out num)) { num--; int currentPageIndex = this._startRowIndex / this._maximumRows; int maxPageIndex = (this._totalRowCount - 1) / this._maximumRows; if ((num >= 0) && (num <= maxPageIndex)) { this._startRowIndex = num * this._maximumRows; validPageIndex = true; } } } //Goto item texbox this.CreateGoToTexBox(container); //Control used to set the page size. this.CreatePageSizeControl(container); //Set of records - total records this.CreateLabelRecordControl(container); if (this._showPreviousPage) { int pageIndex = (this._startRowIndex / this._maximumRows) - 1; container.Controls.Add(this.CreateLink(this.PreviousPageText, pageIndex, this.PreviousPageImageUrl, this.EnablePreviousPage)); this.AddNonBreakingSpace(container); } if (this._showNextPage) { int num4 = (this._startRowIndex + this._maximumRows) / this._maximumRows; container.Controls.Add(this.CreateLink(this.NextPageText, num4, this.NextPageImageUrl, this.EnableNextPage)); this.AddNonBreakingSpace(container); } if (validPageIndex) { base.DataPager.SetPageProperties(this._startRowIndex, this._maximumRows, true); } }
private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex) { bool flag = false; if (!base.QueryStringHandled) { int num; base.QueryStringHandled = true; if (int.TryParse(base.QueryStringValue, out num)) { num--; int num1 = this._startRowIndex / this._maximumRows; int num2 = (this._totalRowCount - 1) / this._maximumRows; if ((num >= 0) && (num <= num2)) { this._startRowIndex = num * this._maximumRows; flag = true; } } } if (this.ShowFirstPageButton) { container.Controls.Add(this.CreateLink("icon-double-angle-left", 0, this.EnablePreviousPage)); } if (this.ShowPreviousPageButton) { int pageIndex = (this._startRowIndex / this._maximumRows) - 1; container.Controls.Add(this.CreateLink("icon-angle-left", pageIndex, this.EnablePreviousPage)); } if (this.ShowNextPageButton) { int num4 = (this._startRowIndex + this._maximumRows) / this._maximumRows; container.Controls.Add(this.CreateLink("icon-angle-right", num4, this.EnableNextPage)); } if (this.ShowLastPageButton) { int num5 = (this._totalRowCount / this._maximumRows) - (((this._totalRowCount % this._maximumRows) == 0) ? 1 : 0); container.Controls.Add(this.CreateLink("icon-double-angle-right", num5, this.EnableNextPage)); } if (flag) { base.DataPager.SetPageProperties(this._startRowIndex, this._maximumRows, true); } }
public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { if (container == null) { return; } RenderNonBreakingSpacesBetweenControls = false; var parent = container.Parent; parent.Controls.Remove(container); var overrideContainer = new ListItemDataPagerFieldItem(container, false, ListItemCssClass); parent.Controls.Add(overrideContainer); base.CreateDataPagers(overrideContainer, startRowIndex, maximumRows, totalRowCount, fieldIndex); }
private void CreateDataPagersForCommand(DataPagerFieldItem container, int fieldIndex) { if (this.ShowFirstPageButton) { container.Controls.Add(this.CreateControl("First", "icon-double-angle-left", fieldIndex, this.EnablePreviousPage)); } if (this.ShowPreviousPageButton) { container.Controls.Add(this.CreateControl("Prev", "icon-angle-left", fieldIndex, this.EnablePreviousPage)); } if (this.ShowNextPageButton) { container.Controls.Add(this.CreateControl("Next", "icon-angle-right", fieldIndex, this.EnableNextPage)); } if (this.ShowLastPageButton) { container.Controls.Add(this.CreateControl("Last", "icon-double-angle-right", fieldIndex, this.EnableNextPage)); } }
private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex) { bool validPageIndex = false; if (!QueryStringHandled) { int num; QueryStringHandled = true; if (int.TryParse(base.QueryStringValue, out num)) { num--; int currentPageIndex = startRowIndex / maximumRows; int maxPageIndex = (totalRowCount - 1) / maximumRows; if ((num >= 0) && (num <= maxPageIndex)) { startRowIndex = num * maximumRows; validPageIndex = true; } } } CreateGoToTexBox(container); CreatePageSizeControl(container); CreateLabelRecordControl(container); int pageIndex = (startRowIndex / maximumRows) - 1; container.Controls.Add(CreateLink(PreviousPageText, pageIndex, PreviousPageImageUrl, EnablePreviousPage)); AddNonBreakingSpace(container); int pagenum = (startRowIndex + maximumRows) / maximumRows; container.Controls.Add(CreateLink(NextPageText, pagenum, NextPageImageUrl, EnableNextPage)); AddNonBreakingSpace(container); if (validPageIndex) { DataPager.SetPageProperties(startRowIndex, maximumRows, true); } }
private void CreateDataPagersForQueryString(DataPagerFieldItem container, int fieldIndex) { int currentPageIndex = _startRowIndex / _maximumRows; bool resetProperties = false; if (!QueryStringHandled) { int currentQSPageIndex; QueryStringHandled = true; bool parsed = Int32.TryParse(QueryStringValue, out currentQSPageIndex); if (parsed) { currentQSPageIndex--;//convert page number to page index. int highestPageIndex = (_totalRowCount - 1) / _maximumRows; if ((currentQSPageIndex >= 0) && (currentQSPageIndex <= highestPageIndex)) { currentPageIndex = currentQSPageIndex; _startRowIndex = (currentPageIndex * _maximumRows); resetProperties = true; } } } int firstButtonIndex = (_startRowIndex / (ButtonCount * _maximumRows)) * ButtonCount; int lastButtonIndex = firstButtonIndex + ButtonCount - 1; int lastRecordIndex = ((lastButtonIndex + 1) * _maximumRows) - 1; if (firstButtonIndex != 0) { container.Controls.Add(CreateNextPrevLink(PreviousPageText, firstButtonIndex - 1, PreviousPageImageUrl)); AddNonBreakingSpace(container); } for (int i = 0; i < ButtonCount && _totalRowCount > ((i + firstButtonIndex) * _maximumRows); i++) { if (i + firstButtonIndex == currentPageIndex) { Label pageNumber = new Label(); pageNumber.Text = (i + firstButtonIndex + 1).ToString(CultureInfo.InvariantCulture); if (!String.IsNullOrEmpty(CurrentPageLabelCssClass)) { pageNumber.CssClass = CurrentPageLabelCssClass; } container.Controls.Add(pageNumber); } else { container.Controls.Add(CreateNumericLink(i + firstButtonIndex)); } AddNonBreakingSpace(container); } if (lastRecordIndex < _totalRowCount - 1) { AddNonBreakingSpace(container); container.Controls.Add(CreateNextPrevLink(NextPageText, firstButtonIndex + ButtonCount, NextPageImageUrl)); AddNonBreakingSpace(container); } if (resetProperties) { DataPager.SetPageProperties(_startRowIndex, _maximumRows, true); } }
private void AddNonBreakingSpace(DataPagerFieldItem container) { container.Controls.Add(new LiteralControl(" ")); }
/// <summary> /// Creates the user interface (UI) controls for the pager field object and adds them to the specified container. /// </summary> /// <param name="container">The container that is used to store the controls.</param> /// <param name="startRowIndex">The index of the first record on the page.</param> /// <param name="maximumRows">The maximum number of items on a single page.</param> /// <param name="totalRowCount">The total number of items.</param> /// <param name="fieldIndex">The index of the data pager field in the <see cref="P:System.Web.UI.WebControls.DataPager.Fields"/> collection.</param> public override void CreateDataPagers(DataPagerFieldItem container, int startRowIndex, int maximumRows, int totalRowCount, int fieldIndex) { int currentPageIndex = startRowIndex / DataPager.PageSize; object currentPageObj = DataPager.Page.Request.QueryString[this.DataPager.QueryStringField]; short currentQSPageIndex; bool resetProperties = false; if (currentPageObj != null) { bool parsed = Int16.TryParse(currentPageObj.ToString(), out currentQSPageIndex); if (parsed) { currentQSPageIndex--; int highestPageIndex = (totalRowCount - 1) / maximumRows; if (currentPageIndex != currentQSPageIndex && currentQSPageIndex <= highestPageIndex) { currentPageIndex = currentQSPageIndex; startRowIndex = (currentPageIndex * DataPager.PageSize); resetProperties = true; } } } int firstButtonIndex = (startRowIndex / (ButtonCount * DataPager.PageSize)) * ButtonCount; int lastButtonIndex = firstButtonIndex + ButtonCount - 1; int lastRecordIndex = ((lastButtonIndex + 1) * DataPager.PageSize) - 1; if (firstButtonIndex != 0) { container.Controls.Add(CreateNextPrevButton(PreviousPageText, firstButtonIndex - 1, PreviousPageImageUrl)); if (RenderNonBreakingSpacesBetweenControls) { container.Controls.Add(new LiteralControl(" ")); } } for (int i = 0; i < ButtonCount && totalRowCount > ((i + firstButtonIndex) * DataPager.PageSize); i++) { if (i + firstButtonIndex == currentPageIndex) { Label pageNumber = new Label(); pageNumber.Text = (i + firstButtonIndex + 1).ToString(CultureInfo.InvariantCulture); if (!String.IsNullOrEmpty(CurrentPageLabelCssClass)) { pageNumber.CssClass = CurrentPageLabelCssClass; } container.Controls.Add(pageNumber); } else { container.Controls.Add(CreateNumericButton(i + firstButtonIndex)); } if (RenderNonBreakingSpacesBetweenControls) { container.Controls.Add(new LiteralControl(" ")); } } if (lastRecordIndex < totalRowCount - 1) { if (RenderNonBreakingSpacesBetweenControls) { container.Controls.Add(new LiteralControl(" ")); } container.Controls.Add(CreateNextPrevButton(NextPageText, firstButtonIndex + ButtonCount, NextPageImageUrl)); if (RenderNonBreakingSpacesBetweenControls) { container.Controls.Add(new LiteralControl(" ")); } } if (resetProperties) { DataPager.SetPageProperties(startRowIndex, maximumRows, true); } }
public ListItemDataPagerFieldItem(DataPagerFieldItem inner, bool labelsAreDisabled, string listItemCssClass) : base(inner.PagerField, inner.Pager) { LabelsAreDisabled = labelsAreDisabled; ListItemCssClass = listItemCssClass; }