Class.aspx.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:3k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Collections;
- using System.Configuration;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.HtmlControls;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- public partial class _Class : System.Web.UI.Page
- {
- Db ebdoing = new Db();
- protected void Page_Load(object sender, EventArgs e)
- {
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- Conn.Open();
- SqlCommand Cls_Cmd = new SqlCommand("select * from Class where ClassID=" + Request.QueryString["ClassID"], Conn);
- SqlDataReader Dr = Cls_Cmd.ExecuteReader();
- if (Dr.Read())
- {
- HiddenField1.Value = Dr["ClassID"].ToString();
- }
- Conn.Close();
- if (!IsPostBack)
- {
- this.labPage.Text = "1";
- this.contrlRepeater();
- }
- SqlConnection R_Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter R_Da = new SqlDataAdapter("select * from News order by shijian desc", R_Conn);
- DataSet R_Ds = new DataSet();
- R_Da.Fill(R_Ds, "News");
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = R_Ds.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 25;
- R_Repeater.DataSource = Pds;
- R_Repeater.DataBind();
- }
- //分页 ^-^
- public void contrlRepeater()
- {
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter Da = new SqlDataAdapter("select * from News where ClassID=" + HiddenField1.Value + "order by NewsID desc", Conn);
- DataSet Ds = new DataSet();
- Da.Fill(Ds, "News");
- PagedDataSource pds = new PagedDataSource();
- pds.DataSource = Ds.Tables["News"].DefaultView;
- pds.AllowPaging = true;
- pds.PageSize = 10;
- Total.Text = pds.DataSourceCount.ToString();
- pds.CurrentPageIndex = Convert.ToInt32(this.labPage.Text) - 1;
- Repeater1.DataSource = pds;
- LabCountPage.Text = pds.PageCount.ToString();
- labPage.Text = (pds.CurrentPageIndex + 1).ToString();
- this.lbtnpritPage.Enabled = true;
- this.lbtnFirstPage.Enabled = true;
- this.lbtnNextPage.Enabled = true;
- this.lbtnDownPage.Enabled = true;
- if (pds.CurrentPageIndex < 1)
- {
- this.lbtnpritPage.Enabled = false;
- this.lbtnFirstPage.Enabled = false;
- }
- if (pds.CurrentPageIndex == pds.PageCount - 1)
- {
- this.lbtnNextPage.Enabled = false;
- this.lbtnDownPage.Enabled = false;
- }
- Repeater1.DataBind();
- }
- protected void lbtnpritPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) - 1);
- this.contrlRepeater();
- }
- protected void lbtnFirstPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = "1";
- this.contrlRepeater();
- }
- protected void lbtnDownPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = this.LabCountPage.Text;
- this.contrlRepeater();
- }
- protected void lbtnNextPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) + 1);
- this.contrlRepeater();
- }
- }