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'");
        }
       }
      }

  • 相关阅读:
    PHP中的无限级分类
    JS中json数据格式取值实例
    PHP中类的延迟绑定
    电阻
    不能做“没事找抽型”投资者
    Delphi相关文件扩展名介绍
    三极管
    沃伦·巴菲特
    电压,电流,电阻的关系就是欧姆定律
    CnPack 使用的组件命名约定
  • 原文地址:https://www.cnblogs.com/aipeli/p/262733.html
Copyright © 2011-2022 走看看