• Gridview 行变色和行按钮调用前端js


    1.鼠标移动某一行 ,变色

    protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    
        {
    
        if (e.Row.RowType == DataControlRowType.DataRow)
    
        {
    
        //鼠标经过时,行背景色变
    
        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
    
        //鼠标移出时,行背景色变
    
        e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
      //设置悬浮鼠标指针形状为“下手”
        e.Row.Attributes["style"] = "cursor:pointer"; } }

     

    2.编辑按钮调用前端的js 方法

     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
              //获取gridview里的编辑按钮
                ImageButton buttonE = new ImageButton();
                buttonE = (ImageButton)e.Row.FindControl("IB_Edit");
                
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
             DataRowView drv = (DataRowView)e.Row.DataItem; string SYSID_Floor = drv["SYSID_Meter"].ToString();           //给按钮添加onclick属性,调用前端的js方法 updateNav() buttonE.Attributes["onclick"] = "return UpdateNav(" + SYSID_Floor + ")"; buttonE.CommandName = "Edit"; } }

     前端js

    <script>
    
     function UpdateNav(floorId) {
    
                //iframe层-父子操作
                var index = layer.open({
                    title: "修改接表点信息",
                    type: 2,
                    area: ['700px', '530px'],
                    fix: false, //不固定
                    maxmin: true,
                    content: "ad_meter_detail.aspx?SYSID=" + floorId
                });
                //重新给指定层设定width、top等
                layer.style(index, {
                    top: '15px'
                });
                return false;
    
            }
    </script>
    View Code
  • 相关阅读:
    [PA2014]Muzeum
    [TJOI2015]概率论
    To Do List
    【洛谷4172】 [WC2006]水管局长(LCT)
    HNOI2019退役记
    hdu 2159 FATE
    USACO 2019 January Contest, Platinum 题解
    luogu4774 [NOI2018]屠龙勇士
    NOI 2019游记
    loj #3145. 「APIO 2019」桥梁
  • 原文地址:https://www.cnblogs.com/youchim/p/5278540.html
Copyright © 2020-2023  润新知