⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delnewsinfo.aspx.cs

📁 一个简单的新闻后台管理系统
💻 CS
字号:
using System;
using System.Data;
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;
using System.Data.SqlClient;

public partial class NewsManage_DelNewsInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //SqlConnection con = DataAccess.CreateConnection();
        //SqlDataAdapter sda = new SqlDataAdapter("select NEWSID,NEWSTITLE,NEWSDATE,t_News.CLASSID,NEWSOURCE,HITS from t_News join t_Class on  t_Class.CLASSID=t_News.CLASSID", con);
        //con.Open();
        //DataSet ds = new DataSet();
        //sda.Fill(ds, "news");
        //this.GridView1.DataSource = ds.Tables["news"].DefaultView;
        //this.GridView1.DataBind();
    }

   
    protected void Button1_Click(object sender, EventArgs e)
    {
       
        GridView1.DataSourceID = "";
        if (this.TextBox2.Text == "")
        {
            if (DropDownList1.SelectedItem.Value=="0")
            {
                SqlConnection con = DataAccess.CreateConnection();
                SqlDataAdapter sda = new SqlDataAdapter("select NEWSID,NEWSTITLE,NEWSDATE,t_News.CLASSID,NEWSOURCE,HITS from t_News join t_Class on  t_Class.CLASSID=t_News.CLASSID", con);
                con.Open();
                DataSet ds = new DataSet();
                sda.Fill(ds, "news");
                this.GridView1.DataSource = ds.Tables["news"].DefaultView;
                this.GridView1.DataBind();
            }
            else
            {
                SqlConnection con = DataAccess.CreateConnection();
                SqlDataAdapter sda = new SqlDataAdapter("select NEWSID,NEWSTITLE,NEWSDATE,t_News.CLASSID,NEWSOURCE,HITS from t_News join t_Class on t_Class.CLASSID=t_News.CLASSID   where t_News.CLASSID='" + DropDownList1.SelectedItem.Value + "'", con);
                con.Open();
                DataSet ds = new DataSet();
                sda.Fill(ds, "news");
                this.GridView1.DataSource = ds.Tables["news"].DefaultView;
                this.GridView1.DataBind();

            }
        }
        else
        {
            SqlConnection con = DataAccess.CreateConnection();
            SqlDataAdapter sda = new SqlDataAdapter("select NEWSID,NEWSTITLE,NEWSDATE,t_News.CLASSID,NEWSOURCE,HITS from t_News join t_Class on t_Class.CLASSID=t_News.CLASSID   where t_News.NEWSTITLE='" +this.TextBox2.Text + "'", con);
            con.Open();
            DataSet ds = new DataSet();
            sda.Fill(ds, "news");
            this.GridView1.DataSource = ds.Tables["news"].DefaultView;
            this.GridView1.DataBind();

        }
        this.TextBox2.Text = "";
    }


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        

        if (e.Row.DataItemIndex == -1)
        {
            return;
        }
        else
        {

            e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.originalcolor=this.style.backgroundColor; this.style.backgroundColor='Silver';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");


        }
     }


    protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.DataItemIndex == -1)
        {
            return;
        }
        else
        {

            e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.originalcolor=this.style.backgroundColor; this.style.backgroundColor='Silver';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");


        }

    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {

    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {

    }
}

⌨️ 快捷键说明

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