View.aspx.cs
上传用户:shjujing
上传日期:2022-07-28
资源大小:11244k
文件大小:3k
源码类别:

Email客户端

开发平台:

Visual C++

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.HtmlControls;
  10. using System.Web.UI.WebControls;
  11. using System.Web.UI.WebControls.WebParts;
  12. public partial class Admin_View : System.Web.UI.Page
  13. {
  14.     //Db是自定义的类
  15.     Db ebdoing = new Db();
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         SqlConnection Conn = new SqlConnection(ebdoing.strConn);
  19.         Conn.Open();
  20.         SqlCommand Cmd = new SqlCommand("select * from News where id =" +Request.QueryString["id"], Conn);
  21.         SqlDataReader Dr = Cmd.ExecuteReader();
  22.         if (Dr.Read())
  23.         {
  24.             biaoti.Text = Dr["biaoti"].ToString();
  25.             ViewFrom.Text = "文章来源:" + Dr["ViewFrom"].ToString();
  26.             Time.Text = "添加时间:" + Dr["Time"].ToString();
  27.             Content.Text = Dr["AltView"].ToString();
  28.         }
  29.         Conn.Close();
  30.         //最新热点
  31.         SqlDataAdapter Da = new SqlDataAdapter("select * from News order by Time desc", Conn);
  32.         DataSet Ds =new DataSet();
  33.         Da.Fill(Ds,"News");
  34.         //PagedDataSource 类封装那些允许数据源控件(如 DataGrid、GridView、DetailsView 和 FormView)执行分页操作的属性。如果控件开发人员需对自定义数据绑定控件提供分页支持,即可使用此类。
  35.         PagedDataSource Pds = new PagedDataSource();
  36.         Pds.DataSource = Ds.Tables["News"].DefaultView;
  37.         Pds.AllowPaging = true;
  38.         Pds.PageSize = 30;
  39.         Repeater1.DataSource = Pds;
  40.         Repeater1.DataBind();
  41.         Conn.Open();
  42.         //最新评论
  43.         SqlDataAdapter Guset_Da = new SqlDataAdapter("select * from Guest where alt_id =" + Request.QueryString["id"]+"order by NewsID desc", Conn);
  44.         DataSet Guest_Ds = new DataSet();
  45.         Guset_Da.Fill(Guest_Ds, "Guest");
  46.         PagedDataSource Guest_Pds = new PagedDataSource();
  47.         Guest_Pds.DataSource = Guest_Ds.Tables["Guest"].DefaultView;
  48.         Ping.Text =  Guest_Pds.Count.ToString();
  49.         Repeater2.DataSource = Guest_Pds;
  50.         Repeater2.DataBind();
  51.     }
  52.     protected void Button1_Click(object sender, EventArgs e)
  53.     {
  54.         SqlConnection Conn = new SqlConnection(ebdoing.strConn);
  55.         Conn.Open();
  56.         string id = Request.QueryString["id"];
  57.         SqlCommand Cmd = new SqlCommand("insert into Guest(Name,Message,alt_id)" + "Values('"+Name.Text+"','"+Message.Text+"','"+id+"')",Conn);
  58.         if (Name.Text != "")
  59.         {
  60.             if (Message.Text != "")
  61.             {
  62.                 Cmd.ExecuteNonQuery();
  63.                 Response.Redirect("./Show.aspx?id=" + Request.QueryString["id"]);
  64.             }
  65.             else
  66.             {
  67.                 Response.Write("<script>alert('请输入评论内容!');history.go(-1);</script>");
  68.             }
  69.         }
  70.         else
  71.         {
  72.             Response.Write("<script>alert('请输入网友昵称!');history.go(-1);</script>");
  73.         }
  74.         Conn.Close();
  75.     }
  76. }