【发布时间】:2013-10-28 12:10:18
【问题描述】:
我正在尝试在 GridView 中的 delete 按钮上单击 时收到 confirmation 消息。如果我 conform 只有该行将在 GridView 中被删除。
*.ASPX
<Columns>
<asp:CommandField ButtonType="Button" ShowDeleteButton="true" />
</Columns>
*.ASPX.CS
protected void grdPersTable_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button buttonCommandField = e.Row.Cells[0].Controls[0] as Button;
buttonCommandField.Attributes["onClick"] =
string.Format("return confirm('Are you want delete ')");
}
}
protected void grdPersTable_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Label lbl0 = (Label)grdPersTable.Rows[e.RowIndex].FindControl("lblId");
txtId.Text = lbl0.Text;
obj.DeleteV(Convert.ToInt32(txtId.Text));
grdPersTable.DataSource = obj.GetTableValues();
grdPersTable.DataBind();
lblMessage.Text = "Deleted successfully !";
}
【问题讨论】: