/// summary>
/// 删除选中的行
/// /summary>
/// param name="sender">/param>
/// param name="e">/param>
protected void gvDepartList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
ImageButton buttom = gvDepartList.Rows[e.RowIndex].FindControl("btnDelete") as ImageButton;
string departId = buttom.CommandArgument.ToString();
if (manage.DeleteDepart(departId))
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "script>alert('删除成功!');/script>");
BindDepartInfos();//重新绑定数据
}
else
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "script>alert('删除失败!');/script>");
}
}
为了更好的用户体验,我们可以不使用这个Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "script>alert('删除成功!');/script>");
可以选择在页面中显眼的地方放一个label控件,设计Visible=false;隐藏它,然后删除成功后,利用这个Label控件来提示用户,删除成功!