温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:达达ASP.NET企业信息管理系统
当前文件路径:DaDaEnterprise/ClsView.aspx.cs

1using System; 2
using System.Collections; 3
using System.Configuration; 4
using System.Data; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.HtmlControls; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
12
public partial class ClsView : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
if (!IsPostBack) 17
{ 18
Title = ConfigurationManager.AppSettings["Web"] + " - 建站心得"; 19
this.labPage.Text = "1"; 20
this.contrlRepeater(); 21
22
string count = "select count(*) from [View] where ClsId='" 23
+ Request.QueryString["id"] + "'"; 24
Count.Text = DataAccess.CountCmd(count).ToString(); 25
26
//左边作品数据源 27
string Works = "select top 15 * from [Works] order by id desc"; 28
Repeater3.DataSource = DataAccess.GetDataSet(Works); 29
Repeater3.DataBind(); 30
31
string cls = "select * from [Class] order by Sort"; 32
DataList1.DataSource = DataAccess.GetDataSet(cls); 33
DataList1.DataBind(); 34
} 35
36
} 37
38
/// <summary> 39
/// 字符截断 40
/// </summary> 41
/// <param name="scatitle"></param> 42
/// <param name="cid"></param> 43
/// <returns></returns> 44
public static string getleft(string scatitle, int cid) 45
{ 46
string rtn = ""; 47
if (scatitle.Trim().Length > cid) 48
{ 49
rtn = scatitle.Substring(0, cid) + "..."; 50
} 51
else 52
{ 53
rtn = scatitle; 54
} 55
return rtn; 56
} 57
58
/// <summary> 59
/// 分页 60
/// </summary> 61
public void contrlRepeater() 62
{ 63
string sql = "select * from [View] where ClsId='"+ 64
Request.QueryString["id"]+"'order by id desc"; 65
DataSet Ds = DataAccess.GetDataSet(sql); 66
67
//使用PagedDataSource来实现分页 68
PagedDataSource pds = new PagedDataSource(); 69
pds.DataSource = Ds.Tables[0].DefaultView; 70
pds.AllowPaging = true; 71
pds.PageSize = 15; 72
Label1.Text = pds.Count.ToString(); 73
pds.CurrentPageIndex = Convert.ToInt32(this.labPage.Text) - 1; 74
Repeater2.DataSource = pds; 75
LabCountPage.Text = pds.PageCount.ToString(); 76
labPage.Text = (pds.CurrentPageIndex + 1).ToString(); 77
this.lbtnpritPage.Enabled = true; 78
this.lbtnFirstPage.Enabled = true; 79
this.lbtnNextPage.Enabled = true; 80
this.lbtnDownPage.Enabled = true; 81
if (pds.CurrentPageIndex < 1) 82
{ 83
this.lbtnpritPage.Enabled = false; 84
this.lbtnFirstPage.Enabled = false; 85
} 86
if (pds.CurrentPageIndex == pds.PageCount - 1) 87
{ 88
this.lbtnNextPage.Enabled = false; 89
this.lbtnDownPage.Enabled = false; 90
} 91
Repeater2.DataBind(); 92
} 93
protected void lbtnpritPage_Click(object sender, EventArgs e) 94
{ 95
this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) - 1); 96
this.contrlRepeater(); 97
} 98
protected void lbtnFirstPage_Click(object sender, EventArgs e) 99
{ 100
this.labPage.Text = "1"; 101
this.contrlRepeater(); 102
} 103
protected void lbtnDownPage_Click(object sender, EventArgs e) 104
{ 105
this.labPage.Text = this.LabCountPage.Text; 106
this.contrlRepeater(); 107
} 108
109
protected void lbtnNextPage_Click(object sender, EventArgs e) 110
{ 111
this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) + 1); 112
this.contrlRepeater(); 113
} 114
} 115





}
}