Protected Sub GvOperInfo_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvOperInfo.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(9).Attributes.Add("onclick", "return confirm('确认修改?')")
End If
End Sub上面是我写的GridView的删除确认代码。可是最终效果是,无论你点击的是“确定”还是“取消”,都会删除记录。
问题出在哪里?
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(9).Attributes.Add("onclick", "return confirm('确认修改?')")
End If
End Sub上面是我写的GridView的删除确认代码。可是最终效果是,无论你点击的是“确定”还是“取消”,都会删除记录。
问题出在哪里?
解决方案 »
- 一个页面有多个Reapter控件,当浏览的时候是一个一个加载吗?
- 如何在IMAGEBUTTON控件上用鼠标显示文字??
- iframe 显示问题
- 无分 问题比较难 求救~!!!慕白兄请进。
- ajaxpro时常报错 web未定义
- asp.net c# 路径问题
- @@@@@@@@@@datagrid帮定的字段,如果在数据库为空,如何取值@@@@@@@@@@
- *******上次提问,没有人回答,再提一个做安装包的问题看看*******
- 受不了了!小妹我不得不问了,在asp.net中页面怎末居中????
- 读取文件问题~~
- 请问关于SQL语句求出在数据表中第二大的值
- 关于IEWebControls的问题,用localhost就能正常显示TreeView,可是用IP就不能访问
如果你是用的CommandField,
把你的这段代码删除,直接把页面里CommandField換成:
<asp:CommandField ShowDeleteButton="True" DeleteText="<div style="display:inline" id="deleteme" onclick="JavaScript:return confirm('确定删除吗?')">删除</div>">
</asp:CommandField>
如果是用的TemplateField,
把你的你代码改成e.Row.Cells(9).FindControl("删除按钮ID").Attributes.Add("onclick", "return confirm('确认修改?')")
我把代码修改成下面这样就OK了。
Protected Sub GridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim BtTemp As New Button
BtTemp = e.Row.Cells(5).FindControl("BtDelete")
BtTemp.OnClientClick = "return confirm('你确定要删除吗?');"
End If
End Sub