zoukankan      html  css  js  c++  java
  • DataGrid删除确认及Item颜色交替

    DataGrid删除确认及Item颜色交替

    hbzxf(阿好)
    http://www.cnblogs.com/hbzxf

               有时候我们需要在删除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'");
        }
       }
      }

  • 相关阅读:
    Python变量状态保持四种方法
    Python参数基础
    Django Form 表单
    Python开发第四篇
    Python开发第三篇
    设计模式(一)概述
    Python自学之路——自定义简单装饰器
    Python开发第二篇
    Python开发第一篇
    Python核心编程——多线程threading和队列
  • 原文地址:https://www.cnblogs.com/aipeli/p/262733.html
Copyright © 2011-2022 走看看