View.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 Admin_View : System.Web.UI.Page
- {
- //Db是自定义的类
- Db ebdoing = new Db();
- protected void Page_Load(object sender, EventArgs e)
- {
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- Conn.Open();
- SqlCommand Cmd = new SqlCommand("select * from News where id =" +Request.QueryString["id"], Conn);
- SqlDataReader Dr = Cmd.ExecuteReader();
- if (Dr.Read())
- {
- biaoti.Text = Dr["biaoti"].ToString();
- ViewFrom.Text = "文章来源:" + Dr["ViewFrom"].ToString();
- Time.Text = "添加时间:" + Dr["Time"].ToString();
- Content.Text = Dr["AltView"].ToString();
- }
- Conn.Close();
- //最新热点
- SqlDataAdapter Da = new SqlDataAdapter("select * from News order by Time desc", Conn);
- DataSet Ds =new DataSet();
- Da.Fill(Ds,"News");
- //PagedDataSource 类封装那些允许数据源控件(如 DataGrid、GridView、DetailsView 和 FormView)执行分页操作的属性。如果控件开发人员需对自定义数据绑定控件提供分页支持,即可使用此类。
- PagedDataSource Pds = new PagedDataSource();
- Pds.DataSource = Ds.Tables["News"].DefaultView;
- Pds.AllowPaging = true;
- Pds.PageSize = 30;
- Repeater1.DataSource = Pds;
- Repeater1.DataBind();
- Conn.Open();
- //最新评论
- SqlDataAdapter Guset_Da = new SqlDataAdapter("select * from Guest where alt_id =" + Request.QueryString["id"]+"order by NewsID desc", Conn);
- DataSet Guest_Ds = new DataSet();
- Guset_Da.Fill(Guest_Ds, "Guest");
- PagedDataSource Guest_Pds = new PagedDataSource();
- Guest_Pds.DataSource = Guest_Ds.Tables["Guest"].DefaultView;
- Ping.Text = Guest_Pds.Count.ToString();
- Repeater2.DataSource = Guest_Pds;
- Repeater2.DataBind();
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- SqlConnection Conn = new SqlConnection(ebdoing.strConn);
- Conn.Open();
- string id = Request.QueryString["id"];
- SqlCommand Cmd = new SqlCommand("insert into Guest(Name,Message,alt_id)" + "Values('"+Name.Text+"','"+Message.Text+"','"+id+"')",Conn);
- if (Name.Text != "")
- {
- if (Message.Text != "")
- {
- Cmd.ExecuteNonQuery();
- Response.Redirect("./Show.aspx?id=" + Request.QueryString["id"]);
- }
- else
- {
- Response.Write("<script>alert('请输入评论内容!');history.go(-1);</script>");
- }
- }
- else
- {
- Response.Write("<script>alert('请输入网友昵称!');history.go(-1);</script>");
- }
- Conn.Close();
- }
- }