zoukankan      html  css  js  c++  java
  • 为DataGrid行添加事件

    private void grid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
      {
       if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer )
       {
        e.Item.Attributes.Add("onmouseover","this.setAttribute('BKC',this.style.backgroundColor);this.style.backgroundColor='#FF0000'");
        e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=this.getAttribute('BKC');");


       }

      }


    private void OnItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
       {
            
    if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer )
            {
                LinkButton btnSave 
    = (LinkButton)e.Item.Cells[2].Controls[0];
          string strClientID 
    = btnSave.ClientID; //得到该控件的客户端ID,可供JavaScript调用
                btnSave.Attributes.Add("onclick","Javascript:return confirm('Are you sure to save?');");
            }
    }

  • 相关阅读:
    017-新闻表分页增删改查
    016-页面生命周期
    015-用户登录注册
    014-Session服务器状态保持
    013-Cookie状态保持
    012-ViewState状态保持
    011-Server服务器对象属性
    010-判断是否回传IsPostBack属性
    Github使用教程
    获取中文时间
  • 原文地址:https://www.cnblogs.com/ltjabc/p/214647.html
Copyright © 2011-2022 走看看