Example #1
0
        protected void btnUpdateStatus_Click(object sender, EventArgs e)
        {
            try
            {
                int enableCount  = 0;
                int disableCount = 0;

                StringBuilder enableBuilder  = new StringBuilder();
                StringBuilder disableBuilder = new StringBuilder();
                foreach (GridViewRow grow in gdvMembers.Rows)
                {
                    CheckBox    chkstatus = (CheckBox)grow.FindControl("chkstatus");
                    HiddenField hdnUserId = (HiddenField)grow.FindControl("hdnUserId");
                    HiddenField hdnStatus = (HiddenField)grow.FindControl("hdnStatus");
                    if (chkstatus.Checked)
                    {
                        if (hdnStatus.Value.ToLower() == "pending" || hdnStatus.Value.ToLower() == "rejected")
                        {
                            enableBuilder = enableBuilder.Append(hdnUserId.Value + ",");
                            enableCount   = enableCount + 1;
                        }
                    }

                    if (!chkstatus.Checked)
                    {
                        if (hdnStatus.Value.ToLower() == "done")
                        {
                            disableBuilder = disableBuilder.Append(hdnUserId.Value + ",");
                            disableCount   = disableCount + 1;
                        }
                    }
                }

                if (enableCount != 0 || disableCount != 0)
                {
                    _regDal.UpdateUserStatus(enableBuilder.ToString().TrimEnd(','),
                                             disableBuilder.ToString().TrimEnd(','));
                    BindData();
                    string msg = string.Format("alert('{0} registrations approved/{1} registrations rejected')", enableCount, disableCount);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", msg, true);
                }
            }
            catch (Exception)
            {
            }
        }