NewsDefault.aspx.cs
资源名称:yjal.rar [点击查看]
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:4k
源码类别:
Email客户端
开发平台:
Visual C++
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class NewsDefault : System.Web.UI.Page
- {
- Db ebdoing = new Db();
- protected void Page_Load(object sender, EventArgs e)
- {
- //显示企业新闻
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter Da1 = new SqlDataAdapter("Select * from News where ClassID=1 order by NewsID desc", Conn);
- DataSet Ds1 = new DataSet();
- Da1.Fill(Ds1, "News");
- //PagedDataSource 类封装那些允许数据源控件(如 DataGrid、GridView、DetailsView 和 FormView)执行分页操作的属性。如果控件开发人员需对自定义数据绑定控件提供分页支持,即可使用此类。
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = Ds1.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 16;
- Repeater1.DataSource = Pds;
- Repeater1.DataBind();
- Rep2();
- Rep3();
- Rep4();
- R();
- }
- public void Rep2()
- {
- //显示企业新闻
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter Da1 = new SqlDataAdapter("Select * from News where ClassID=2 order by NewsID desc", Conn);
- DataSet Ds1 = new DataSet();
- Da1.Fill(Ds1, "News");
- //PagedDataSource 类封装那些允许数据源控件(如 DataGrid、GridView、DetailsView 和 FormView)执行分页操作的属性。如果控件开发人员需对自定义数据绑定控件提供分页支持,即可使用此类。
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = Ds1.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 16;
- Repeater2.DataSource = Pds;
- Repeater2.DataBind();
- }
- public void Rep3()
- {
- //显示国内新闻
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter Da1 = new SqlDataAdapter("Select * from News where ClassID=3 order by NewsID desc", Conn);
- DataSet Ds1 = new DataSet();
- Da1.Fill(Ds1, "News");
- //PagedDataSource 类封装那些允许数据源控件(如 DataGrid、GridView、DetailsView 和 FormView)执行分页操作的属性。如果控件开发人员需对自定义数据绑定控件提供分页支持,即可使用此类。
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = Ds1.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 16;
- Repeater3.DataSource = Pds;
- Repeater3.DataBind();
- }
- public void Rep4()
- {
- //显示国际新闻
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter Da1 = new SqlDataAdapter("Select * from News where ClassID=4 order by NewsID desc", Conn);
- DataSet Ds1 = new DataSet();
- Da1.Fill(Ds1, "News");
- //PagedDataSource 类封装那些允许数据源控件(如 DataGrid、GridView、DetailsView 和 FormView)执行分页操作的属性。如果控件开发人员需对自定义数据绑定控件提供分页支持,即可使用此类。
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = Ds1.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 16;
- Repeater4.DataSource = Pds;
- Repeater4.DataBind();
- }
- public void R()
- {
- //最新更新 新闻列表
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- SqlDataAdapter DaR = new SqlDataAdapter("Select * from News order by NewsID desc", Conn);
- DataSet DsR = new DataSet();
- DaR.Fill(DsR, "News");
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = DsR.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 25;
- RepeaterR.DataSource = Pds;
- RepeaterR.DataBind();
- }
- }