C# GridView 给某行或某列绑定点击事件和鼠标事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
protected void GridViewEx1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)//判断单击行是否为数据行 
        
             DataRowView row = (DataRowView)e.Row.DataItem; 
             e.Row.ID = GridViewEx1.DataKeys[e.Row.RowIndex]["ID"].ToString();//ID为唯一能够标识一条记录的字段 
             if (e.Row.ID != null && row != null
             
                e.Row.Cells[1].Attributes.Add("ondblclick", "window.open('ParhelionRestEdittPage.aspx?index=" + (e.Row.RowIndex + 1).ToString() + "&id=" + e.Row.Cells[0].Text.Trim() + "',null,'width=400,height=108,left=300,top=200');");
 
                e.Row.Cells[1].Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F89E14',this.style.cursor='pointer';"); 
                 //鼠标事件 this.style.backgroundColor='#F89E14' 列背景色  this.style.cursor='pointer' 鼠标放上去样式 
                e.Row.Cells[1].Attributes.Add("onmouseout", "this.style.backgroundColor='';"); 
             
          
       }
   }

  

posted @   每天进步多一点  阅读(4865)  评论(0编辑  收藏  举报
编辑推荐:
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 2 本地部署DeepSeek模型构建本地知识库+联网搜索详细步骤
点击右上角即可分享
微信分享提示