博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DataGrid删除确认及Item颜色交替
阅读量:1982 次
发布时间:2019-04-27

本文共 774 字,大约阅读时间需要 2 分钟。

有时候我们需要在删除DataGrid中Item相对应的数据时,需要弹出一个确认对话框来提示使用者,其实这个功能非常简单,下面的代码可以在DataGrid的Item 中产生颜色交替的效果。    

 private void dg_ItemDataBound(object sender, DataGridItemEventArgs e)

  {
   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
   {
 //删除确认            
    LinkButton delBttn = (LinkButton) e.Item.Cells[1].Controls[0];
    delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除" + e.Item.Cells[4].Text + "?');"); 
 //颜色交替   
    e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'");
    if(e.Item.ItemType == ListItemType.Item)
    {
     e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
    }

    if(e.Item.ItemType ==ListItemType.AlternatingItem)

    {
     e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'");
    }
   }
  }

转载地址:http://wfwvf.baihongyu.com/

你可能感兴趣的文章
CentOS 系统下Postfix邮件系统配置
查看>>
nginx auth认证保护
查看>>
linux 画图不执行 Can't connect to X11 window server
查看>>
Myeclipse 错误:JVM terminated. Exit code=255
查看>>
matlab2014a win安装教程
查看>>
MATLAB 编译java步骤
查看>>
Linux服务器命令行模式安装 matlab2015a linux64
查看>>
linux 下多个java jdk 切换
查看>>
Kd-Tree算法原理
查看>>
CentOS 6 下编译安装nginx 参数配置
查看>>
linux 查看文件夹下的文件个数
查看>>
CentOS6.5 下编译安装php-5.6.3.tar.gz
查看>>
ubuntu vi 方向键、删除键问题
查看>>
ubuntu14.04安装cuda
查看>>
IP Tracker 追踪
查看>>
tensorflow的Virtualenv安装方式安装
查看>>
Chrome.storage和HTML5中localStorage的差异
查看>>
三种EBS类型解析
查看>>
HttpClients4.*版本超时设置
查看>>
Solr ShingleFilter
查看>>