admin/Plinluns.aspx.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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 admin_Plinluns : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!base.IsPostBack)
        {
            login.pd();
            aa();

        }
        
    }
    private void aa()
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["CJRdata"]);
        con.Open();
        SqlCommand cmd = new SqlCommand();//声明一个SqlCommand的 cmd对象,并将其实例化
        SqlDataAdapter sda = new SqlDataAdapter("select * from Comment order by data desc", con);
        DataSet ds = new DataSet();         //声明一个DataSet的ds对象,并将其实例化
        sda.Fill(ds, "comment");
        this.GridView2.DataSource = ds.Tables[0].DefaultView;
        this.GridView2.DataKeyNames = new string[] { "id" };
        this.GridView2.DataBind();//将数据绑定到GridView控件中file:///D:\成功网站\admin\shedit.aspx
        con.Close();
    }
    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView2.PageIndex = e.NewPageIndex;
        this.aa();//调用用户自定义的函数
    }
    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'");
            e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
            ((LinkButton)(e.Row.Cells[6].Controls[0])).Attributes.Add("onclick", "return confirm('确定删除吗?')");
            e.Row.Cells[4].Text = Convert.ToDateTime(e.Row.Cells[4].Text).ToShortDateString();

        }
    }
    protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int title = Convert.ToInt32(this.GridView2.DataKeys[e.RowIndex].Value.ToString());
        SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["CJRdata"]);
        con.Open();
        SqlCommand cmd = new SqlCommand("delete from Comment where id=" + title + "", con);
        cmd.ExecuteNonQuery();
后面还有 40 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。