1  数据绑定GridView时的事件

#region 数据绑定GridView时的事件
        protected void GV_Data_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int index = Convert.ToInt32(e.Row.RowIndex.ToString());
                LinkButton LB_Edit=e.Row.Cells[4].FindControl("LB_Modify") as LinkButton;
                LB_Edit.CommandArgument = this.GV_Data.DataKeys[index]["Dic_Id"].ToString();
                LinkButton LB_Del = e.Row.Cells[4].FindControl("LB_Del") as LinkButton;
                LB_Del.Attributes.Add("onclick","javascript : return confirm('是否确认删除?')");
                LB_Del.CommandArgument = this.GV_Data.DataKeys[index]["Dic_Id"].ToString();

                //设置行样式,当鼠标移动到该行时变色

                e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E4F4FD'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");
            }
        }
        #endregion

2 点击列表上的超链接所产生的事件

 #region 点击列表上的超链接所产生的事件
        protected void GV_Data_RowCommand(object sender, GridViewCommandEventArgs e)
        {
                        
            //如果点击的是编辑
            if (e.CommandName == "Modify")
            {
                                   
            }
            //如果点击的是删除
            if (e.CommandName == "Del")
            {
                            }
        }
        #endregion


相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2022-01-23
  • 2021-06-25
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2021-06-26
  • 2022-12-23
  • 2021-10-13
  • 2021-07-24
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
相关资源
相似解决方案