日期:2014-05-19  浏览次数:20417 次

GridView删除时提示的问题
在VS2005中
我的GridView   绑定的顺序是这样的
第一列       第二列     第三列     第四列  

用户名         密码         编辑         删除

                protected   void   GridView1_RowDataBound(object   sender,   GridViewRowEventArgs   e)
                {
                        if   (e.Row.RowType   ==   DataControlRowType.DataRow)
                        {
                                ((LinkButton)(e.Row.Cells[3].Controls[0])).Attributes.Add( "onclick ",   "return   confirm( '你确定要删除码? '); ");
                        }
                }

上面的这句可以实现删除时提示   但是点击编辑的时候   就包这样的错误   请问怎么解决啊   是不是点击编辑的时候e.Row.Cells[3].Controls[0]的值就改动了啊?

------解决方案--------------------
就包这样的错误?什么样的错误?
------解决方案--------------------
e.Row.Cells[3]这就是表示第四列
点击编辑也弹出confirm?
------解决方案--------------------
<asp:TemplateField ShowHeader= "False ">
<ItemTemplate>
<asp:LinkButton ID= "LinkButton1 " runat= "server " CausesValidation= "False " CommandName= "Delete "
Text= "删除 " OnClientClick= "return confirm( '确定要删除??? ') "> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
------解决方案--------------------
什么样的错误?
((LinkButton)(e.Row.Cells[3].Controls[0])).Attributes.Add( "onclick ", "JavaScript:return confirm( '你确定要删除码? '); ");
------解决方案--------------------
那不是脚本的错误,是你处理绑定的参数有错误...