当前位置:编程学习 > C#/ASP.NET >>

求教gridview行点击和按钮点击冲突问题

protected void GridFileList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //加入鼠标滑过的高亮效果
            if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行ss是否属于datarow类型的行
            {
                string s = "APPID=" + GridFileList.DataKeys[e.Row.RowIndex].Value + "";
                e.Row.Attributes.Add("onclick", "javascript:location.href=\"JingPinContentManage.aspx?" + s + "\"");
                e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';this.style.cursor='hand';");
                ////当鼠标离开的时候 将背景颜色还原的以前的颜色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
                //e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='hand';"); 

                Button btn =(Button)e.Row.FindControl("btnDelete");  
                btn.Attributes.Add("onclick", "return confirm('确认删除吗?')");
                                  
            }
        }


这里有个问题,我点击行上的删除按钮也会触发行点击事件,点击行上的checkbox也会触发行点击事件!求教 --------------------编程问答-------------------- 可以在前台给btnDelete加一个confirm确认撒 --------------------编程问答-------------------- 不管是确认还是不确认都会触发行点击啊 --------------------编程问答-------------------- 继续求教啊!来个高人呗!!! --------------------编程问答--------------------  搜索下网上

javascript 事件冒泡 --------------------编程问答-------------------- 看看这样行不行
btn.Attributes.Add("onclick", "return confirm('确认删除吗?'); return false");
--------------------编程问答-------------------- 点击方式分开,行点击用双击 --------------------编程问答-------------------- 加上列的判断就行了
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,