【发布时间】:2012-03-08 05:30:47
【问题描述】:
我想在用户尝试删除详细视图中的记录时提示用户确认?我有命令文件,其中 showDeletebutton 设置为 true。
我找到了如何对gridview进行确认,但是如何修改以匹配详细视图?
代码:
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// loop all data rows
foreach (DataControlFieldCell cell in e.Row.Cells)
{
// check all cells in one row
foreach (Control control in cell.Controls)
{
// Must use LinkButton here instead of ImageButton
// if you are having Links (not images) as the command button.
ImageButton button = control as ImageButton;
if (button != null && button.CommandName == "Delete")
// Add delete confirmation
button.OnClientClick = "if (!confirm('Are you sure " +
"you want to delete this record?')) return;";
}
}
}
}
有人吗?
【问题讨论】: