不用gridview,datalist等控件分页怎么写 5
2个回答
展开全部
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>图书列表</title>
<link href="css/StyleSheet.css" rel="stylesheet" type="text/css" id="css" />
<script type="text/javascript">
var id = 0;
var pageIndex = 1;
var order = "";
var pageSize = 1;
function getBookList(rs)
{
var ds = rs.value;
for(var i = 0; i < ds.Tables[0].Rows.length; i++)
{
var li = document.createElement("li");
var a = document.createElement("a");
a.innerText = ds.Tables[0].Rows[i]["Name"];
a.id = ds.Tables[0].Rows[i]["Id"];
a.onclick = function()
{
pageIndex = 1;
order = "";
id = this.id;
document.getElementById("books").innerHTML = "";
myAjax.getPage(id,getPage);
myAjax.getBooks(pageIndex,id,order,getBooks);
}
li.appendChild(a);
document.getElementById("left").appendChild(li);
}
}
function getBooks(rs)
{
var ds = rs.value;
var tb;
var tr;
var td;
var db;
var img;
for(var i = 0; i < ds.Tables[0].Rows.length; i++)
{
img = document.createElement("img")
img.style.width = 100;
img.style.height = 150;
img.border = 0;
img.src = "BookCovers/"+ ds.Tables[0].Rows[i]["ISBN"] +".jpg";
td = document.createElement("td");
td.width = 100;
td.rowSpan = 3;
td.appendChild(img);
tr = document.createElement("tr");
tr.appendChild(td);
td = document.createElement("td");
td.innerText = ds.Tables[0].Rows[i]["Title"];
td.width = 450;
td.id = "tdTitle";
tr.appendChild(td);
db = document.createElement("tbody");
db.appendChild(tr);
tr = document.createElement("tr");
td = document.createElement("td");
td.innerText = "作者:"+ds.Tables[0].Rows[i]["Author"];
td.width = 450;
td.id = "tdAuthor";
tr.appendChild(td);
db.appendChild(tr);
tr = document.createElement("tr");
td = document.createElement("td");
td.innerHTML = "描述:"+getString(ds.Tables[0].Rows[i]["ContentDescription"])+"......<br>出版日期:"+ds.Tables[0].Rows[i]["PublishDate"]+"<br>价格:"+ds.Tables[0].Rows[i]["UnitPrice"];
td.width = 450;
td.id = "tdAuthor";
tr.appendChild(td);
db.appendChild(tr);
td = document.createElement("table");
td.appendChild(db);
document.getElementById("books").appendChild(td);
}
}
function getString(str)
{
return str.length > 200 ? str.substring(0,200) : str;
}
function PublishDate_onclick(str) {
order = str;
document.getElementById("books").innerHTML = "";
myAjax.getBooks(pageIndex,id,order,getBooks);
}
function getPage(rs)
{
pageSize = rs.value;
}
function Page_onclick(str)
{
if(str=="Up")
{
if(pageIndex == 1)
{
alert("已经是第一页了!");
}
else
{
pageIndex -= 1;
document.getElementById("books").innerHTML = "";
myAjax.getBooks(pageIndex,id,order,getBooks);
}
}
else
{
if(pageIndex == pageSize)
{
alert("已经是最后一页了!");
}
else
{
pageIndex += 1;
document.getElementById("books").innerHTML = "";
myAjax.getBooks(pageIndex,id,order,getBooks);
}
}
}
function red()
{
var cs = document.getElementById("css");
cs.href = "css/red.css";
}
function b()
{
var cs = document.getElementById("css");
cs.href = "css/StyleSheet.css";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="main">
<div id="left">
<p id="bookList">
图 书 列 表</p>
</div>
<div id="right">
<p id="order">
排序方式:
<input id="PublishDate" type="button" value="出版日期" onclick="PublishDate_onclick('PublishDate')" />
<input id="UnitPrice" type="button" value="价 格" onclick="PublishDate_onclick('UnitPrice')" />
<input id="Button1" type="button" value="红" onclick="red()" />
<input id="Button2" type="button" value="蓝" onclick="b()" />
</p>
<div id="books">
</div>
<p id="page">
<input id="Up" type="button" value="上一页" onclick="Page_onclick('Up')" />
<input id="Down" type="button" value="下一页" onclick="Page_onclick('Down')" />
</p>
</div>
</div>
<script type="text/javascript">
myAjax.getBookList(getBookList);
</script>
</form>
</body>
</html>
--------------------------cs文件代码----------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 AjaxPro;
using System.Collections.Generic;
[AjaxNamespace("myAjax")]
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Utility.RegisterTypeForAjax(typeof(Index));
}
private SqlConnection sqlcon;
private SqlCommand sqlcom;
private SqlDataAdapter da;
private DataSet ds;
private string sqlCon = "server=.;database=MyBookShop;uid=sa";
[AjaxMethod]
public DataSet getBookList()
{
ds = new DataSet();
da = new SqlDataAdapter("select * from Categories", sqlCon);
da.Fill(ds);
return ds;
}
[AjaxMethod]
public int getPage(string id)
{
ds = new DataSet();
da = new SqlDataAdapter("select * from books where CategoryId = '"+id+"'", sqlCon);
da.Fill(ds);
int page = ds.Tables[0].Rows.Count;
return (page + 5 - 1) / 5;
}
[AjaxMethod]
public DataSet getBooks(int pageIndex, string id, string order)
{
sqlcon = new SqlConnection(sqlCon);
sqlcom = new SqlCommand();
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Connection = sqlcon;
sqlcom.CommandText = "GetPaginationRecord";
List<SqlParameter> sqlPar = new List<SqlParameter>();
sqlPar.Add(new SqlParameter("@tableName", "Books"));
sqlPar.Add(new SqlParameter("@fieldKey", "Id"));
sqlPar.Add(new SqlParameter("@pageSize", 5));
sqlPar.Add(new SqlParameter("@pageIndex", pageIndex));
if (order == "")
{
sqlPar.Add(new SqlParameter("@sqlOrder", ""));
}
else
{
sqlPar.Add(new SqlParameter("@sqlOrder", "order by " + order + " asc "));
}
sqlPar.Add(new SqlParameter("@sqlWhere", " CategoryId = " + id + " "));
sqlcom.Parameters.AddRange(sqlPar.ToArray());
ds = new DataSet();
da = new SqlDataAdapter();
da.SelectCommand = sqlcom;
da.Fill(ds);
return ds;
}
}
这是ajax pro 做的分页,思路就是这样的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>图书列表</title>
<link href="css/StyleSheet.css" rel="stylesheet" type="text/css" id="css" />
<script type="text/javascript">
var id = 0;
var pageIndex = 1;
var order = "";
var pageSize = 1;
function getBookList(rs)
{
var ds = rs.value;
for(var i = 0; i < ds.Tables[0].Rows.length; i++)
{
var li = document.createElement("li");
var a = document.createElement("a");
a.innerText = ds.Tables[0].Rows[i]["Name"];
a.id = ds.Tables[0].Rows[i]["Id"];
a.onclick = function()
{
pageIndex = 1;
order = "";
id = this.id;
document.getElementById("books").innerHTML = "";
myAjax.getPage(id,getPage);
myAjax.getBooks(pageIndex,id,order,getBooks);
}
li.appendChild(a);
document.getElementById("left").appendChild(li);
}
}
function getBooks(rs)
{
var ds = rs.value;
var tb;
var tr;
var td;
var db;
var img;
for(var i = 0; i < ds.Tables[0].Rows.length; i++)
{
img = document.createElement("img")
img.style.width = 100;
img.style.height = 150;
img.border = 0;
img.src = "BookCovers/"+ ds.Tables[0].Rows[i]["ISBN"] +".jpg";
td = document.createElement("td");
td.width = 100;
td.rowSpan = 3;
td.appendChild(img);
tr = document.createElement("tr");
tr.appendChild(td);
td = document.createElement("td");
td.innerText = ds.Tables[0].Rows[i]["Title"];
td.width = 450;
td.id = "tdTitle";
tr.appendChild(td);
db = document.createElement("tbody");
db.appendChild(tr);
tr = document.createElement("tr");
td = document.createElement("td");
td.innerText = "作者:"+ds.Tables[0].Rows[i]["Author"];
td.width = 450;
td.id = "tdAuthor";
tr.appendChild(td);
db.appendChild(tr);
tr = document.createElement("tr");
td = document.createElement("td");
td.innerHTML = "描述:"+getString(ds.Tables[0].Rows[i]["ContentDescription"])+"......<br>出版日期:"+ds.Tables[0].Rows[i]["PublishDate"]+"<br>价格:"+ds.Tables[0].Rows[i]["UnitPrice"];
td.width = 450;
td.id = "tdAuthor";
tr.appendChild(td);
db.appendChild(tr);
td = document.createElement("table");
td.appendChild(db);
document.getElementById("books").appendChild(td);
}
}
function getString(str)
{
return str.length > 200 ? str.substring(0,200) : str;
}
function PublishDate_onclick(str) {
order = str;
document.getElementById("books").innerHTML = "";
myAjax.getBooks(pageIndex,id,order,getBooks);
}
function getPage(rs)
{
pageSize = rs.value;
}
function Page_onclick(str)
{
if(str=="Up")
{
if(pageIndex == 1)
{
alert("已经是第一页了!");
}
else
{
pageIndex -= 1;
document.getElementById("books").innerHTML = "";
myAjax.getBooks(pageIndex,id,order,getBooks);
}
}
else
{
if(pageIndex == pageSize)
{
alert("已经是最后一页了!");
}
else
{
pageIndex += 1;
document.getElementById("books").innerHTML = "";
myAjax.getBooks(pageIndex,id,order,getBooks);
}
}
}
function red()
{
var cs = document.getElementById("css");
cs.href = "css/red.css";
}
function b()
{
var cs = document.getElementById("css");
cs.href = "css/StyleSheet.css";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="main">
<div id="left">
<p id="bookList">
图 书 列 表</p>
</div>
<div id="right">
<p id="order">
排序方式:
<input id="PublishDate" type="button" value="出版日期" onclick="PublishDate_onclick('PublishDate')" />
<input id="UnitPrice" type="button" value="价 格" onclick="PublishDate_onclick('UnitPrice')" />
<input id="Button1" type="button" value="红" onclick="red()" />
<input id="Button2" type="button" value="蓝" onclick="b()" />
</p>
<div id="books">
</div>
<p id="page">
<input id="Up" type="button" value="上一页" onclick="Page_onclick('Up')" />
<input id="Down" type="button" value="下一页" onclick="Page_onclick('Down')" />
</p>
</div>
</div>
<script type="text/javascript">
myAjax.getBookList(getBookList);
</script>
</form>
</body>
</html>
--------------------------cs文件代码----------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 AjaxPro;
using System.Collections.Generic;
[AjaxNamespace("myAjax")]
public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Utility.RegisterTypeForAjax(typeof(Index));
}
private SqlConnection sqlcon;
private SqlCommand sqlcom;
private SqlDataAdapter da;
private DataSet ds;
private string sqlCon = "server=.;database=MyBookShop;uid=sa";
[AjaxMethod]
public DataSet getBookList()
{
ds = new DataSet();
da = new SqlDataAdapter("select * from Categories", sqlCon);
da.Fill(ds);
return ds;
}
[AjaxMethod]
public int getPage(string id)
{
ds = new DataSet();
da = new SqlDataAdapter("select * from books where CategoryId = '"+id+"'", sqlCon);
da.Fill(ds);
int page = ds.Tables[0].Rows.Count;
return (page + 5 - 1) / 5;
}
[AjaxMethod]
public DataSet getBooks(int pageIndex, string id, string order)
{
sqlcon = new SqlConnection(sqlCon);
sqlcom = new SqlCommand();
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Connection = sqlcon;
sqlcom.CommandText = "GetPaginationRecord";
List<SqlParameter> sqlPar = new List<SqlParameter>();
sqlPar.Add(new SqlParameter("@tableName", "Books"));
sqlPar.Add(new SqlParameter("@fieldKey", "Id"));
sqlPar.Add(new SqlParameter("@pageSize", 5));
sqlPar.Add(new SqlParameter("@pageIndex", pageIndex));
if (order == "")
{
sqlPar.Add(new SqlParameter("@sqlOrder", ""));
}
else
{
sqlPar.Add(new SqlParameter("@sqlOrder", "order by " + order + " asc "));
}
sqlPar.Add(new SqlParameter("@sqlWhere", " CategoryId = " + id + " "));
sqlcom.Parameters.AddRange(sqlPar.ToArray());
ds = new DataSet();
da = new SqlDataAdapter();
da.SelectCommand = sqlcom;
da.Fill(ds);
return ds;
}
}
这是ajax pro 做的分页,思路就是这样的
展开全部
<div id="printshow3">
<table width="100%" height="34" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="17">
</td>
<td valign="top" background="../images/next_bg.jpg">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 22px">
</td>
<td style="height: 22px">
<asp:LinkButton ID="btnFirst" runat="server" CssClass="line" CommandArgument="first"
OnClick="btnFirst_Click">首页</asp:LinkButton>
<asp:LinkButton ID="btnPrev" runat="server" CssClass="line" CommandArgument="prev"
OnClick="btnPrev_Click">上一页</asp:LinkButton>
<asp:LinkButton ID="btnNext" runat="server" CssClass="line" CommandArgument="next"
OnClick="btnNext_Click">下一页</asp:LinkButton>
<asp:LinkButton ID="btnLast" runat="server" CssClass="line" CommandArgument="last"
OnClick="btnLast_Click">尾页</asp:LinkButton>
<font color="#000000"> 页码:<asp:TextBox ID="GoPage" onkeyup="value=value.replace(/[^\d\.]/g,'')"
runat="server" Width="25px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" CssClass="button_jdkd" Text="跳转" Width="36px"
Height="20px" OnClick="Button1_Click1" OnClientClick="return chkyema();" />
每页<font color="red">12</font>条数据 共有<font color="red"><asp:Label
ID="Label1_total" runat="server" ForeColor="Red" Text="0"></asp:Label></font>条数据
当前为第<font color="red"><asp:Label ID="Label2_curpage" runat="server"
ForeColor="Red" Text="0"></asp:Label></font>页 共<font color="red"><asp:Label
ID="Label3_totalpage" runat="server" ForeColor="Red" Text="0"></asp:Label></font>页</font>
</td>
</tr>
</table>
</td>
<td width="17">
</td>
</tr>
</table>
</div>
这些写在gridview下面,不是gridview里面
后台:
Pager = 0;
Count = 0;
SortExpression = "";
Direction = "";
Message = "";//几个关键东西
private int Pager
{
get { return (int)ViewState["Page"]; }
set { ViewState["Page"] = value; }
}
private string Message
{
get { return (string)ViewState["Message"]; }
set { ViewState["Message"] = value; }
}
private string SortExpression
{
get { return (string)ViewState["sortExpression"]; }
set { ViewState["sortExpression"] = value; }
}
private string Direction
{
get { return (string)ViewState["direction"]; }
set { ViewState["direction"] = value; }
}
private int Count
{
get { return Convert.ToInt32(ViewState["count"]) - 1; }
set { ViewState["count"] = value; }
}
private void setEnable(PagedDataSource source)
{
this.btnFirst.Enabled = true;
this.btnPrev.Enabled = true;
this.btnNext.Enabled = true;
this.btnLast.Enabled = true;
if (source.IsFirstPage)
{
this.btnFirst.Enabled = false;
this.btnPrev.Enabled = false;
}
if (source.IsLastPage)
{
this.btnNext.Enabled = false;
this.btnLast.Enabled = false;
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
try
{
if (Convert.ToInt32(GoPage.Text.Trim()) - 1 <= Count && Convert.ToInt32(this.GoPage.Text.Trim()) - 1 >= 0)
{
Pager = Convert.ToInt32(GoPage.Text.Trim()) - 1;
databind();
}
else
{
GoPage.Text = "1";
}
}
catch { }
}
protected void PagerButtonClick(object sender, EventArgs e)
{
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (ViewState["SortDirection"] == null)
{
ViewState["SortDirection"] = SortDirection.Descending;
}
else
{
string sortExpression = e.SortExpression;
if (ViewState["SortDirection"].ToString() == SortDirection.Ascending.ToString()) //设置排序方向
{
ViewState["SortDirection"] = SortDirection.Descending;
SortExpression = sortExpression;
Direction = " DESC";
databind();
}
else
{
ViewState["SortDirection"] = SortDirection.Ascending;
SortExpression = sortExpression;
Direction = " asc";
databind();
}
}
}
/// <summary>
/// 首页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnFirst_Click(object sender, EventArgs e)
{
Pager = 0;
databind();
}
/// <summary>
/// 上一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrev_Click(object sender, EventArgs e)
{
Pager--;
databind();
}
/// <summary>
/// 下一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNext_Click(object sender, EventArgs e)
{
Pager++;
databind();
}
/// <summary>
/// 尾页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnLast_Click(object sender, EventArgs e)
{
Pager = Count;
databind();
}
//这是绑定gridview
DataSet ds = new DataSet();
ds = da.employeeinfo_select(Server, "tb_shjmb", strSQL);
//DataSet dss = new DataSet();
//dss = da.employeeinfo_select(Server, "tb_shjmblist", strSQL);
PagedDataSource source = new PagedDataSource();
DataView dv = ds.Tables[0].DefaultView;
dv.Sort = SortExpression + Direction;
source.DataSource = dv;
source.AllowPaging = true;
source.PageSize = 12;
source.CurrentPageIndex = Pager;
Count = source.PageCount;
this.GridView1.DataSource = null;
this.GridView1.DataSource = source;
this.GridView1.DataBind();
//状态栏中显示数据记录条数
Label1_total.Text = ds.Tables[0].Rows.Count.ToString();
//状态栏显示页数
Label2_curpage.Text = (source.CurrentPageIndex + 1).ToString();
Label3_totalpage.Text = source.PageCount.ToString();
ds.Dispose();
setEnable(source);
<table width="100%" height="34" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="17">
</td>
<td valign="top" background="../images/next_bg.jpg">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 22px">
</td>
<td style="height: 22px">
<asp:LinkButton ID="btnFirst" runat="server" CssClass="line" CommandArgument="first"
OnClick="btnFirst_Click">首页</asp:LinkButton>
<asp:LinkButton ID="btnPrev" runat="server" CssClass="line" CommandArgument="prev"
OnClick="btnPrev_Click">上一页</asp:LinkButton>
<asp:LinkButton ID="btnNext" runat="server" CssClass="line" CommandArgument="next"
OnClick="btnNext_Click">下一页</asp:LinkButton>
<asp:LinkButton ID="btnLast" runat="server" CssClass="line" CommandArgument="last"
OnClick="btnLast_Click">尾页</asp:LinkButton>
<font color="#000000"> 页码:<asp:TextBox ID="GoPage" onkeyup="value=value.replace(/[^\d\.]/g,'')"
runat="server" Width="25px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" CssClass="button_jdkd" Text="跳转" Width="36px"
Height="20px" OnClick="Button1_Click1" OnClientClick="return chkyema();" />
每页<font color="red">12</font>条数据 共有<font color="red"><asp:Label
ID="Label1_total" runat="server" ForeColor="Red" Text="0"></asp:Label></font>条数据
当前为第<font color="red"><asp:Label ID="Label2_curpage" runat="server"
ForeColor="Red" Text="0"></asp:Label></font>页 共<font color="red"><asp:Label
ID="Label3_totalpage" runat="server" ForeColor="Red" Text="0"></asp:Label></font>页</font>
</td>
</tr>
</table>
</td>
<td width="17">
</td>
</tr>
</table>
</div>
这些写在gridview下面,不是gridview里面
后台:
Pager = 0;
Count = 0;
SortExpression = "";
Direction = "";
Message = "";//几个关键东西
private int Pager
{
get { return (int)ViewState["Page"]; }
set { ViewState["Page"] = value; }
}
private string Message
{
get { return (string)ViewState["Message"]; }
set { ViewState["Message"] = value; }
}
private string SortExpression
{
get { return (string)ViewState["sortExpression"]; }
set { ViewState["sortExpression"] = value; }
}
private string Direction
{
get { return (string)ViewState["direction"]; }
set { ViewState["direction"] = value; }
}
private int Count
{
get { return Convert.ToInt32(ViewState["count"]) - 1; }
set { ViewState["count"] = value; }
}
private void setEnable(PagedDataSource source)
{
this.btnFirst.Enabled = true;
this.btnPrev.Enabled = true;
this.btnNext.Enabled = true;
this.btnLast.Enabled = true;
if (source.IsFirstPage)
{
this.btnFirst.Enabled = false;
this.btnPrev.Enabled = false;
}
if (source.IsLastPage)
{
this.btnNext.Enabled = false;
this.btnLast.Enabled = false;
}
}
protected void Button1_Click1(object sender, EventArgs e)
{
try
{
if (Convert.ToInt32(GoPage.Text.Trim()) - 1 <= Count && Convert.ToInt32(this.GoPage.Text.Trim()) - 1 >= 0)
{
Pager = Convert.ToInt32(GoPage.Text.Trim()) - 1;
databind();
}
else
{
GoPage.Text = "1";
}
}
catch { }
}
protected void PagerButtonClick(object sender, EventArgs e)
{
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
if (ViewState["SortDirection"] == null)
{
ViewState["SortDirection"] = SortDirection.Descending;
}
else
{
string sortExpression = e.SortExpression;
if (ViewState["SortDirection"].ToString() == SortDirection.Ascending.ToString()) //设置排序方向
{
ViewState["SortDirection"] = SortDirection.Descending;
SortExpression = sortExpression;
Direction = " DESC";
databind();
}
else
{
ViewState["SortDirection"] = SortDirection.Ascending;
SortExpression = sortExpression;
Direction = " asc";
databind();
}
}
}
/// <summary>
/// 首页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnFirst_Click(object sender, EventArgs e)
{
Pager = 0;
databind();
}
/// <summary>
/// 上一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPrev_Click(object sender, EventArgs e)
{
Pager--;
databind();
}
/// <summary>
/// 下一页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNext_Click(object sender, EventArgs e)
{
Pager++;
databind();
}
/// <summary>
/// 尾页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnLast_Click(object sender, EventArgs e)
{
Pager = Count;
databind();
}
//这是绑定gridview
DataSet ds = new DataSet();
ds = da.employeeinfo_select(Server, "tb_shjmb", strSQL);
//DataSet dss = new DataSet();
//dss = da.employeeinfo_select(Server, "tb_shjmblist", strSQL);
PagedDataSource source = new PagedDataSource();
DataView dv = ds.Tables[0].DefaultView;
dv.Sort = SortExpression + Direction;
source.DataSource = dv;
source.AllowPaging = true;
source.PageSize = 12;
source.CurrentPageIndex = Pager;
Count = source.PageCount;
this.GridView1.DataSource = null;
this.GridView1.DataSource = source;
this.GridView1.DataBind();
//状态栏中显示数据记录条数
Label1_total.Text = ds.Tables[0].Rows.Count.ToString();
//状态栏显示页数
Label2_curpage.Text = (source.CurrentPageIndex + 1).ToString();
Label3_totalpage.Text = source.PageCount.ToString();
ds.Dispose();
setEnable(source);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询