📄 binddata.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
/// <summary>
/// Pading 的摘要说明
/// </summary>
public class BindData
{
BuildClass bc = new BuildClass();
HouseClass hc = new HouseClass();
public BindData() { }
string strCon = ConfigurationSettings.AppSettings["ConnectionString"].ToString();
#region 贮存过程手工分页
//首页,上一页,下一页,尾页
public void Command(string commandName, HiddenField hiddenCurrentPage, int pageTotal)
{
switch (commandName)
{
case "firstPage":
hiddenCurrentPage.Value = "1";
break;
case "upPage":
hiddenCurrentPage.Value = (int.Parse(hiddenCurrentPage.Value) - 1).ToString();
break;
case "nextPage":
hiddenCurrentPage.Value = (int.Parse(hiddenCurrentPage.Value) + 1).ToString();
break;
case "lastPage":
hiddenCurrentPage.Value = pageTotal.ToString();
break;
}
}
//分页数据绑定
public int PadingBindData(DataList dataList, HiddenField hiddenCurrentPage, LinkButton lbtnFirstPage, LinkButton lbtnUpPage, LinkButton lbtnNextPage, LinkButton lbtnLastPage, Label lblPageList, Label lblPageTotal,string iD,string procedure,int pageSize,string para)
{
int currentPage = int.Parse(hiddenCurrentPage.Value);
SqlParameter[] paras = { new SqlParameter("@CurrentPage", currentPage), new SqlParameter("@PageSize", pageSize), new SqlParameter("@InfoCount",SqlDbType.Int) ,new SqlParameter("@Para",para)};
paras[2].Direction = ParameterDirection.Output;
DataSet ds = Real.DAL.SqlHelper.ExecuteDataset(strCon, CommandType.StoredProcedure,procedure, paras);
dataList.DataSource = ds;
dataList.DataKeyField = iD;
dataList.DataBind();
int pageTotal;
double infoCount = Convert.ToInt32(paras[2].Value);
if (infoCount % pageSize == 0)
{
pageTotal = int.Parse(Math.Ceiling(infoCount / pageSize).ToString());
}
else
{
int infoCounts = Convert.ToInt32(infoCount);
pageTotal = Convert.ToInt32(infoCounts / pageSize + 1);
}
lbtnFirstPage.Enabled = hiddenCurrentPage.Value != "1";
lbtnUpPage.Enabled = hiddenCurrentPage.Value != "1";
lbtnNextPage.Enabled = hiddenCurrentPage.Value != pageTotal.ToString();
lbtnLastPage.Enabled = hiddenCurrentPage.Value != pageTotal.ToString();
lblPageList.Text = "";
for (int i = 1; i <= pageTotal; i++)
{
if (currentPage == i)
{
lblPageList.Text += i + " ";
}
else
{
lblPageList.Text += "<a href=\"javascript:ChangePage(" + i + ")\">" + i + "</a> ";
}
lblPageTotal.Text = "一共有" + pageTotal.ToString() + "页";
}
return pageTotal;
}
public int PadingBindData(DataList dataList, HiddenField hiddenCurrentPage, LinkButton lbtnFirstPage, LinkButton lbtnUpPage, LinkButton lbtnNextPage, LinkButton lbtnLastPage, Label lblPageList, Label lblPageTotal, string iD, string procedure, int pageSize)
{
int currentPage = int.Parse(hiddenCurrentPage.Value);
SqlParameter[] paras = { new SqlParameter("@CurrentPage", currentPage), new SqlParameter("@PageSize", pageSize), new SqlParameter("@InfoCount", SqlDbType.Int) };
paras[2].Direction = ParameterDirection.Output;
DataSet ds = Real.DAL.SqlHelper.ExecuteDataset(strCon, CommandType.StoredProcedure, procedure, paras);
dataList.DataSource = ds;
dataList.DataKeyField = iD;
dataList.DataBind();
int pageTotal;
double infoCount = Convert.ToInt32(paras[2].Value);
if (infoCount % pageSize == 0)
{
pageTotal = int.Parse(Math.Ceiling(infoCount / pageSize).ToString());
}
else
{
int infoCounts = Convert.ToInt32(infoCount);
pageTotal = Convert.ToInt32(infoCounts / pageSize + 1);
}
lbtnFirstPage.Enabled = hiddenCurrentPage.Value != "1";
lbtnUpPage.Enabled = hiddenCurrentPage.Value != "1";
lbtnNextPage.Enabled = hiddenCurrentPage.Value != pageTotal.ToString();
lbtnLastPage.Enabled = hiddenCurrentPage.Value != pageTotal.ToString();
lblPageList.Text = "";
for (int i = 1; i <= pageTotal; i++)
{
if (currentPage == i)
{
lblPageList.Text += i + " ";
}
else
{
lblPageList.Text += "<a href=\"javascript:ChangePage(" + i + ")\">" + i + "</a> ";
}
lblPageTotal.Text = "一共有" + pageTotal.ToString() + "页";
}
return pageTotal;
}
public int PadingBindData(DataList dataList, HiddenField hiddenCurrentPage, LinkButton lbtnFirstPage, LinkButton lbtnUpPage, LinkButton lbtnNextPage, LinkButton lbtnLastPage, Label lblPageList, Label lblPageTotal, string iD, string procedure, int pageSize,int para)
{
int currentPage = int.Parse(hiddenCurrentPage.Value);
SqlParameter[] paras = { new SqlParameter("@CurrentPage", currentPage), new SqlParameter("@PageSize", pageSize), new SqlParameter("@InfoCount", SqlDbType.Int),new SqlParameter("@Para",para) };
paras[2].Direction = ParameterDirection.Output;
DataSet ds = Real.DAL.SqlHelper.ExecuteDataset(strCon, CommandType.StoredProcedure, procedure, paras);
dataList.DataSource = ds;
dataList.DataKeyField = iD;
dataList.DataBind();
int pageTotal;
double infoCount = Convert.ToInt32(paras[2].Value);
if (infoCount % pageSize == 0)
{
pageTotal = int.Parse(Math.Ceiling(infoCount / pageSize).ToString());
}
else
{
int infoCounts = Convert.ToInt32(infoCount);
pageTotal = Convert.ToInt32(infoCounts / pageSize + 1);
}
lbtnFirstPage.Enabled = hiddenCurrentPage.Value != "1";
lbtnUpPage.Enabled = hiddenCurrentPage.Value != "1";
lbtnNextPage.Enabled = hiddenCurrentPage.Value != pageTotal.ToString();
lbtnLastPage.Enabled = hiddenCurrentPage.Value != pageTotal.ToString();
lblPageList.Text = "";
for (int i = 1; i <= pageTotal; i++)
{
if (currentPage == i)
{
lblPageList.Text += i + " ";
}
else
{
lblPageList.Text += "<a href=\"javascript:ChangePage(" + i + ")\">" + i + "</a> ";
}
lblPageTotal.Text = "一共有" + pageTotal.ToString() + "页";
}
return pageTotal;
}
#endregion
#region 外置手工分页
public int Padings(HiddenField hiddenCurrentPage, LinkButton lbtnUpPage, LinkButton lbtnNextPage, LinkButton lbtnFirstPage,LinkButton lbtnLastPage,DropDownList drdlstPageList, DataList dlstList, string ID, int PageSize, Page pages,BuildClass bc,double startPrice,double endPrice,Label lblPageCount)
{
int count = 0;
int currentPage = int.Parse(hiddenCurrentPage.Value);
PagedDataSource pds = new PagedDataSource();
DataTable dt = bc.GetSearchInfo(bc, startPrice, endPrice).Tables[0];
if (dt.Rows.Count > 0)
{
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
pds.PageSize = PageSize;
pds.CurrentPageIndex = currentPage - 1;
count = pds.PageCount;
lblPageCount.Text = "共有" + count.ToString() + "页";
if (drdlstPageList.Items.Count > 0)
{
drdlstPageList.Items.Clear();
}
for (int i = 1; i <= pds.PageCount; i++)
{
drdlstPageList.Items.Add(i.ToString());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -