GridView

本文介绍了一种在ASP.NET中优化GridView控件交互的方法,包括实现行点击跳转功能及鼠标悬停样式改变等,提高了用户体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            {
                //鼠标移动到每项时颜色交替效果  
                e.Row.Attributes.Add("OnMouseOut", "this.style.backgroundColor='White';this.style.color='#000000'");
                e.Row.Attributes.Add("OnMouseOver", "this.style.backgroundColor='#dcdcdc';this.style.color='#8C4510'");

                //设置悬浮鼠标指针形状为"小手"  
                e.Row.Attributes["style"] = "Cursor:hand";
            }

            //行点击事件(传参)
            Label LB_FRMID = (Label)e.Row.Cells[6].FindControl("FRMID");
            string FRMID = LB_FRMID.Text.ToString().Trim();
            Label LB_GATE = (Label)e.Row.Cells[7].FindControl("GATE");
            string GATE = LB_GATE.Text.ToString().Trim();
            //连接路径
            Label FRMNO = (Label)e.Row.Cells[5].FindControl("FRMNO");
            if (myData.GetFrmPath(FRMNO.Text.ToString().Trim()).Tables[0].Rows.Count != 0)
            {
                string FrmPath1 = myData.GetFrmPath(FRMNO.Text.ToString().Trim()).Tables[0].Rows[0]["FRMKD"].ToString();
                string FrmPath2 = FRMNO.Text;
                string FrmPath3 = myData.GetFrmPath(FRMNO.Text.ToString().Trim()).Tables[0].Rows[0]["FILENAME"].ToString();
                string conna = System.Configuration.ConfigurationManager.AppSettings["FrmStrg"];
                string FrmPath = conna + FrmPath1 + "/" + FrmPath2 + "/" + FrmPath3;
                string FRMTB = myData.GetFrmPath(FRMNO.Text.ToString().Trim()).Tables[0].Rows[0]["FRMTB"].ToString();//取table名

                for (int i = 0; i <= 3; i++)
                {
                    e.Row.Cells[i].Attributes.Add("onclick", string.Format("location.href='{0}'", "" + FrmPath + "?FRMID=" + FRMID + "&GATE=X&FRMTB=" + FRMTB + ""));
                }

                //e.Row.Cells[4].Attributes.Add("onclick", string.Format("location.href='{0}'", "GoReturn.aspx?FRMID=" + FRMID + "&GATE=X&FRMTB=" + FRMTB + ""));
                e.Row.Cells[4].Attributes.Add("onclick", "javascript:OpenEditWin('GoReturn.aspx?FRMID=" + FRMID + "&FRMNO=" + FrmPath2 + "&FRMTB=" + FRMTB + "',700,500)");
            }

        }

    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值