using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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;
using System.Xml.Linq;

public partial class manage_newsdel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string sql0 = "select * from news order by nid desc";
        GridView1.DataSource = oper.dt(sql0);
        GridView1.DataKeyNames = new string[] {"nid"};
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Int32 delid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);
        string sql0 = "delete from news where nid=" + delid;
        oper.opertb(sql0);
        Response.Redirect("newsdel.aspx");

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ((LinkButton)(e.Row.Cells[2].Controls[0])).Attributes.Add("onclick", "return confirm('你确认要删除嘛？')");
        }

    }
}
