温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:明日供求信息网源码
当前文件:
MingriGongQiu/ShowPage/webGY.aspx.cs,打开代码结构图
MingriGongQiu/ShowPage/webGY.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
12
public partial class ShowPage_webGY : System.Web.UI.Page 13
{ 14
Operation operation = new Operation(); 15
static string infoType = ""; 16
static string infoKey = ""; 17
static PagedDataSource pds = new PagedDataSource(); 18
19
protected void Page_Load(object sender, EventArgs e) 20
{ 21
if (!IsPostBack) 22
{ 23
infoType = "公寓信息"; 24
infoKey = Convert.ToString(Session["key"]); 25
this.DataListBind(); 26
27
dlCharge.DataSource = operation.SelectLeaguerInfo(true, infoType); 28
dlCharge.DataBind(); 29
Session["key"] = null; 30
} 31
} 32
/// <summary> 33
/// 将数据绑定到DataList控件 34
/// </summary> 35
public void DataListBind() 36
{ 37
pds = operation.PageDataListBind(infoType, infoKey, Convert.ToInt32(lblCurrentPage.Text), 10); 38
lnkBtnFirst.Enabled = true; //控件翻页控件都设置为可用 39
lnkBtnLast.Enabled = true; 40
lnkBtnNext.Enabled = true; 41
lnkBtnPrevious.Enabled = true; 42
if (lblCurrentPage.Text == "1") //如果当前显示第一页,“第一页”和“上一页”按钮不可用。 43
{ 44
lnkBtnPrevious.Enabled = false; 45
lnkBtnFirst.Enabled = false; 46
} 47
if (lblCurrentPage.Text == pds.PageCount.ToString()) //如果显示最后一页,“末一页”和“下一页”按钮不可用。 48
{ 49
lnkBtnNext.Enabled = false; 50
lnkBtnLast.Enabled = false; 51
} 52
lblSumPage.Text = pds.PageCount.ToString(); //实现总页数 53
dlFree.DataSource = pds; //绑定数据源 54
dlFree.DataKeyField = "id"; 55
dlFree.DataBind(); 56
} 57
protected void lnkBtnFirst_Click(object sender, EventArgs e) 58
{ 59
lblCurrentPage.Text = "1"; 60
DataListBind(); 61
} 62
protected void lnkBtnPrevious_Click(object sender, EventArgs e) 63
{ 64
lblCurrentPage.Text = (Convert.ToInt32(lblCurrentPage.Text) - 1).ToString(); 65
DataListBind(); 66
} 67
protected void lnkBtnNext_Click(object sender, EventArgs e) 68
{ 69
lblCurrentPage.Text = (Convert.ToInt32(lblCurrentPage.Text) + 1).ToString(); 70
DataListBind(); 71
} 72
protected void lnkBtnLast_Click(object sender, EventArgs e) 73
{ 74
lblCurrentPage.Text = lblSumPage.Text; 75
DataListBind(); 76
} 77
} 78




Operation operation 
}
}