zoukankan      html  css  js  c++  java
  • GridView如何实现点击某行的指定列弹出新窗体

    在Gridview的rowdatabind事件中添加如下代码:
    protected void GVData_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowIndex > -1) { //循环每列 判断需要添加打开新窗体脚本的列 如果改行任意位置都能打开新窗体 则 直接执行if内代码 将cell改为e.Row foreach (TableCell cell in e.Row.Cells) { if (e.Row.Cells.GetCellIndex(cell) != 0&&e.Row.Cells.GetCellIndex(cell) !=10&&e.Row.Cells.GetCellIndex(cell) !=11) { //模版列 要获取到空间的值 如果是BoundFiled 直接去Text值即可 Label lblId = (Label)e.Row.Cells[0].FindControl("LabVisible"); //弹出新窗体 cell.Attributes.Add("onclick", "window.showModalDialog('../GiveScore/DetailMoonDetailResult.aspx?Id=" + lblId.Text + "','','dialogWidth=700px;dialogHeight=500px')"); } } //鼠标以上的样式 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#c8c7c6'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;"); //鼠标样式 e.Row.Style.Add("cursor", "hand"); }
    记录一下 方便以后查阅。

      

  • 相关阅读:
    C# 5注释
    C# 4关键字
    C# 3练习题
    python之子类调用父类的同名属性和方法
    python之继承
    python之对象删除和输出
    python之r,w,a
    python之类中的方法和属性
    python之面向对象
    python之os对文件的操作
  • 原文地址:https://www.cnblogs.com/sulei4471/p/2792049.html
Copyright © 2011-2022 走看看