D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\WebControls\PaginatorCompositeBase.cs
/*
* This file was generated by ProCG version 2.0
*
* File name: Northwind\WebControls\PaginatorCompositeBase.cs
* Language: C# - ADO.Net
* Database: My Sql
*
* Copyright (c) 2002-2019 iGenXSoft.
* For more information visit http://www.igenxsoft.com
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Northwind.General;
using Northwind.Data;
namespace Northwind.WebControls
{
[ToolboxData("<{0}:PaginatorComposite runat=server></{0}:PaginatorComposite>")]
public class PaginatorCompositeBase : NorthwindCompositeControl
{
public int NumPagesToShow
{
get
{
if (this.ViewState["NumPagesToShow"] == null)
return 99; // all
else
return Convert.ToInt32(ViewState["NumPagesToShow"]);
}
set
{
ViewState["NumPagesToShow"] = value.ToString();
}
}
protected override void CreateChildControls()
{
this.Controls.Clear();
base.CreateChildControls();
if (CollectionDataSourceControl.DataCollection == null)
return;
int currentPage = this.CollectionDataSourceControl.CurrentPage;
if (this.CollectionDataSourceControl.NumPages <= 1)
return;
Literal literal = new Literal();
literal.EnableViewState = false;
int i;
int numPagesBeforeCurrent = NumPagesBeforeCurrent;
for (i = 0; i < numPagesBeforeCurrent; i++)
{
LinkButton linkButton = new LinkButton();
this.Controls.Add(linkButton);
linkButton.EnableViewState = false;
int pageNum = (currentPage + 1) - numPagesBeforeCurrent + i;
linkButton.ID = "Page" + pageNum;
linkButton.CommandName = "Page";
linkButton.CommandArgument = (pageNum).ToString();
linkButton.Click += new EventHandler(linkButton_Click);
//linkButton.CssClass = "PageNums";
linkButton.Attributes["style"] = "font-family: Arial; font-size: 11px; color: #084b78;";
linkButton.Text = "[ " + (pageNum) + " ]";
literal = new Literal();
this.Controls.Add(literal);
literal.EnableViewState = false;
literal.Text = " ";
}
// Current Page
LinkButton linkButton1 = new LinkButton();
this.Controls.Add(linkButton1);
linkButton1.EnableViewState = false;
int pageNum1 = currentPage + 1;
linkButton1.ID = "Page" + pageNum1;
linkButton1.CommandName = "Page";
linkButton1.CommandArgument = (currentPage).ToString();
linkButton1.Enabled = false;
linkButton1.Attributes["style"] = "font-family: Arial; font-size: 11px; color: #084b78;";
linkButton1.Text = "Page " + (pageNum1) + " ";
/*
literal = new Literal();
this.Controls.Add(literal);
literal.Text = "<span style='font-family: Arial; font-size: 11px; color: #084b78;'>Page " + (currentPage + 1) + "</span> ";
literal.EnableViewState = false;
*/
int numPagesAfterCurrent = NumPagesAfterCurrent;
for (i = 0; i < numPagesAfterCurrent; i++)
{
LinkButton linkButton = new LinkButton();
this.Controls.Add(linkButton);
linkButton.EnableViewState = false;
int pageNum = currentPage + i + 1;
linkButton.ID = "Page" + (pageNum+1);
linkButton.CommandName = "Page";
linkButton.CommandArgument = (pageNum + 1).ToString();
linkButton.Click += new EventHandler(linkButton_Click);
//linkButton.CssClass = "PageNums";
linkButton.Attributes["style"] = "font-family: Arial; font-size: 11px; color: #084b78;";
linkButton.Text = "[ " + (pageNum + 1) + " ]";
literal = new Literal();
this.Controls.Add(literal);
literal.EnableViewState = false;
literal.Text = " ";
}
}
public override void DataBind()
{
CreateChildControls();
}
void linkButton_Click(object sender, EventArgs e)
{
LinkButton linkButton = (LinkButton)sender;
CollectionDataSourceControl.CurrentPage = Convert.ToInt32(linkButton.CommandArgument) - 1;
RecreateChildControls();
//this.Page.DataBind();
// CmmandName is = "Page";
RaiseBubbleEvent(sender, e);
}
protected int NumPagesBeforeCurrent
{
get
{
int numPagesBefore = NumPagesToShow / 2;
int i = 0;
for (i = 1; i <= numPagesBefore; i++)
{
if ((CollectionDataSourceControl.CurrentPage+1) - i > 0)
continue;
else
{
i--;
break;
}
}
return i;
}
}
protected int NumPagesAfterCurrent
{
get
{
int numPagesAfter = NumPagesToShow - NumPagesBeforeCurrent - 1;
int i = 0;
for (i = 1; i <= numPagesAfter; i++)
{
if (CollectionDataSourceControl.CurrentPage + i < CollectionDataSourceControl.NumPages)
continue;
else
{
i--;
break;
}
}
return i;
}
}
}
}
// 4951 ProCG uses this line - don't edit it