newsview.aspx.cs

来自「大中型酒店管理系统」· CS 代码 · 共 41 行

CS
41
字号
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 newsview : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = db.createconn();
        conn.Open();

        SqlCommand cmd = new SqlCommand("select * from news where newsid ='" + Request.QueryString["id"] + "'", conn);
        SqlDataReader dr = cmd.ExecuteReader();

        if (dr.Read())
        {
            lbltitle.Text = dr["newstitle"].ToString();
            if (dr["newspic"].ToString() == "")
            {
                this.Image1.Visible = false;
            }
            else
            {
                Image1.ImageUrl = "up/" + dr["newspic"].ToString();
            }
            lblauthor.Text = "文章作者:" + dr["newsauthor"].ToString();
            lbltime.Text = "添加时间:" + dr["newsdate"].ToString();
            string content = dr["newscontent"].ToString();
            lblcontent.Text = content.Replace("\r", "<br>");
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?