您目前尚未登陆,请选择【登陆】或【注册
首页->留言本类->太糊留言板(VS2008+SQL2005)>>ShowMes.ascx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:太糊留言板(VS2008+SQL2005)
当前文件:文件类型 TaiHuMessage/ShowMes.ascx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Collections; 3using System.Configuration; 4using System.Data; 5using System.Linq; 6using System.Web; 7using System.Web.Security; 8using System.Web.UI; 9using System.Web.UI.HtmlControls; 10using System.Web.UI.WebControls; 11using System.Web.UI.WebControls.WebParts; 12using System.Xml.Linq; 13using System.Data.SqlClient; 14 15public partial class ShowMes : System.Web.UI.UserControl 16{ 17 DB DBManage = new DB(); 18 string curpage; 19 protected void Page_Load(object sender, EventArgs e) 20 { 21 if(!IsPostBack ) 22 23 BindData(); 24 } 25 public void BindData() 26 { 27 this.Button1.Enabled = true ; 28 this.Button2.Enabled = true ; 29 this.Button3.Enabled = true ; 30 this.Button4.Enabled = true ; 31 SqlDataAdapter sda = new SqlDataAdapter(); 32 sda.SelectCommand = new SqlCommand("select name,content,time from mes order by id DESC", DBManage.GetConnection()); 33 DataSet ds = new DataSet(); 34 sda.Fill(ds ,"dsmes"); 35 PagedDataSource ps = new PagedDataSource(); 36 ps.AllowPaging = true; 37 ps.DataSource = ds.Tables["dsmes"].DefaultView; 38 ps.PageSize = 5; 39 curpage = this.Label1.Text; 40 ps.CurrentPageIndex = Convert.ToInt32(curpage) - 1; 41 42 43 44 this.DataList1 .DataSource = ps; 45 this.DataList1.DataBind(); 46 DBManage.pagetotal = ps.PageCount; 47 this.Label2.Text =""+Convert .ToString( DBManage.pagetotal)+""; 48 this.temp.Text =Convert.ToString ( ps.PageCount); 49 if (Convert.ToInt32(curpage) == 1) 50 { 51 52 this.Button1.Enabled = false; 53 this.Button2.Enabled = false; 54 } 55 if (Convert.ToInt32(curpage) == ps.PageCount) 56 { 57 58 this.Button3.Enabled = false; 59 this.Button4.Enabled = false; 60 } 61 //for (int i = 1; i <= ps.PageCount; i++) 62 //{ 63 64 // this.DropDownList1.Items.Add("第" + i + "页"); 65 //} 66 if (!IsPostBack) 67 for (int i = 1; i <= ps.PageCount; i++) 68 { 69 70 this.DropDownList1.Items.Add("" + i + ""); 71 } 72 73 DBManage.CloseConnection(); 74 } 75 76 protected void Button1_Click(object sender, EventArgs e) 77 { 78 this.Label1.Text = "1"; 79 this.DropDownList1.SelectedIndex = Convert.ToInt32(this.Label1.Text); 80 BindData(); 81 82 } 83 protected void Button2_Click(object sender, EventArgs e) 84 { 85 this.Label1.Text =Convert .ToString ( Convert .ToInt32 ( this.Label1.Text) - 1); 86 this.DropDownList1.SelectedIndex = Convert.ToInt32(this.Label1.Text); 87 BindData(); 88 } 89 protected void Button3_Click(object sender, EventArgs e) 90 { 91 this.Label1.Text = Convert.ToString(Convert.ToInt32(this.Label1.Text) + 1); 92 BindData(); 93 } 94 protected void Button4_Click(object sender, EventArgs e) 95 { 96 this.Label1.Text = this.temp.Text; 97 98 BindData(); 99 } 100 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 101 { 102 this.Label1.Text =Convert .ToString ( Convert .ToInt32 ( this.DropDownList1.SelectedIndex)+1); 103 BindData(); 104 } 105} 106
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:太糊留言板(VS2008+SQL2005)
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号