Esempio n. 1
0
        protected void ctlDelete_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in ctlUserGrid.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
                {
                    try
                    {
                        long   userId = UIHelper.ParseLong(ctlUserGrid.DataKeys[row.RowIndex].Value.ToString());
                        SuUser user   = SuUserService.FindProxyByIdentity(userId);

                        SuUserService.Delete(user);
                    }
                    catch (Exception ex)
                    {
                        if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                                    "alert('This data is now in use.');", true);
                        }
                    }
                }
            }

            // Bind Grid After Delete User Successful.
            ctlUserGrid.DataBind();
        }