itemmanage.aspx.cs

来自「一个简单的新闻后台管理系统」· CS 代码 · 共 55 行

CS
55
字号
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;

public partial class NewsItemManage_ItemManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            
        }
        catch (NullReferenceException err)
        {
            Response.Write(err.Message);
        }
    }
    
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {        
        try
        {            
            int a = Convert.ToInt32((GridView1.Rows[e.RowIndex].Cells[3].Text));
        }
        catch (Exception err)
        {
            Response.Write(err.Message);
        }
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //当鼠标移动到记录上时,其背景颜色发生变化
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            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;");
        }
        //提示是否删除
        if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowType != DataControlRowType.Header
            && e.Row.RowType != DataControlRowType.Footer && e.Row.RowType != DataControlRowType.EmptyDataRow
            && e.Row.RowState != DataControlRowState.Edit && e.Row.RowState != (DataControlRowState.Alternate | DataControlRowState.Edit))
        {
            ((LinkButton)e.Row.Cells[5].Controls[0]).Attributes.Add("onclick", "return confirm('你确认要删除 [ " + e.Row.Cells[1].Text + " ] 吗?');");

        }        
    }
}

⌨️ 快捷键说明

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