Asp.net源码专业站
首页->留言本类->yeal简化留言板源代码(学习版)>>show.ascx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:yeal简化留言板源代码(学习版)
当前文件:文件类型 531TWIN5UOV431/show.ascx.cs[2K,2009-6-12 11:31:10]打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11using System.Data.OleDb; 12 13public partial class show : System.Web.UI.UserControl 14{ 15 //downLoad From 51aspx.com 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 if (!this.IsPostBack) 19 { 20 this.pre.CausesValidation = false; 21 this.pre1.CausesValidation = false; 22 this.next.CausesValidation = false; 23 this.next1.CausesValidation = false; 24 this.now.Text = "1"; 25 this.now1.Text = this.now.Text; 26 this.bindToDatalist(); 27 } 28 } 29 private void bindToDatalist() 30 { 31 int curPage = Convert.ToInt32(this.now.Text); 32 OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + 33 System.Web.HttpContext.Current.Server.MapPath("App_Data/db.mdb")); 34 OleDbDataAdapter oda = new OleDbDataAdapter(); 35 oda.SelectCommand = new OleDbCommand("select * from guestBook order by gTime DESC",conn); 36 DataSet ds = new DataSet(); 37 oda.Fill(ds, "gb"); 38 PagedDataSource ps = new PagedDataSource(); 39 ps.DataSource = ds.Tables["gb"].DefaultView; 40 ps.AllowPaging = true; 41 ps.PageSize = 10; 42 this.msgall.Text=ps.DataSourceCount.ToString(); 43 this.msgall1.Text = this.msgall.Text; 44 ps.CurrentPageIndex = curPage-1; 45 this.pre.Enabled=true; 46 this.pre1.Enabled=this.pre.Enabled; 47 this.next.Enabled = true; 48 this.next1.Enabled = this.next.Enabled; 49 if (curPage == 1) 50 { 51 this.pre.Enabled = false; 52 this.pre1.Enabled = this.pre.Enabled; 53 } 54 if (curPage == ps.PageCount) 55 { 56 this.next.Enabled = false; 57 this.next1.Enabled = this.next.Enabled; 58 } 59 this.all.Text = ps.PageCount.ToString(); 60 this.all1.Text = this.all.Text; 61 this.DataList1.DataSource = ps; 62 this.DataList1.DataBind(); 63 } 64 protected void pre_Click(object sender, ImageClickEventArgs e) 65 { 66 this.now.Text = Convert.ToString((Convert.ToInt32(this.now.Text) - 1)); 67 this.now1.Text = this.now.Text; 68 this.bindToDatalist(); 69 } 70 protected void next_Click(object sender, ImageClickEventArgs e) 71 { 72 this.now.Text = Convert.ToString((Convert.ToInt32(this.now.Text) + 1)); 73 this.now1.Text = this.now.Text; 74 this.bindToDatalist(); 75 } 76} 77
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:yeal简化留言板源代码(学习版)
51Aspx.com 版权所有 CopyRight © 2006-2010. 京ICP备06046876号 本站法律顾问:ITlaw-庄毅雄律师
返回顶部
客户服务:点击这里进行客户咨询 业务合作:点击这里洽谈业务合作 合作热线:010-68880146