protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //if (txtFirstName.Text.Trim().Length > 0 && txtLastName.Text.Trim().Length > 0 && txtEmail.Text.Trim().Length > 0 && DropDownGroup.SelectedIndex > 0)
            //{
            if (btnSubmit.Text.Equals("Submit"))
            {

                if (hdneditId.Value != null && hdneditId.Value != "" && int.Parse(hdneditId.Value.ToString()) > 0)
                {
                    AccreditationDataContext objDB = new AccreditationDataContext();
                    objDB.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                    using (AccreditationDataContext group = new AccreditationDataContext())
                    {
                        LINQ.TblUserRegistration grp = objDB.TblUserRegistrations.First(D => D.UserId == int.Parse(hdneditId.Value.ToString()));
                        if (grp.UserEmail.Trim() == txtEmail.Text.Trim())
                        {
                            grp.UserFirstName = txtFirstName.Text.Trim();
                            grp.UserLastName = txtLastName.Text.Trim();
                            grp.UserEmail = txtEmail.Text.Trim();
                            grp.Group = Convert.ToInt16(DropDownGroup.SelectedItem.Value);
                            grp.UpdatedOn = DateTime.Now;
                            grp.UpdatedBy = Session["UserEmail"].ToString();
                            grp.userRole = DropdownUserrole.SelectedItem.Value;
                            //grp.Active = true;

                            objDB.SubmitChanges();
                            showOutputMessage((int)BLL.Constants.MessageType.Success, "User Updated Successully.");

                        }
                        else
                        {
                            if (!IsExistEmail(txtEmail.Text.Trim(), int.Parse(hdneditId.Value.ToString())))
                            {
                                grp.UserFirstName = txtFirstName.Text.Trim();
                                grp.UserLastName = txtLastName.Text.Trim();
                                grp.UserEmail = txtEmail.Text.Trim();
                                grp.Group = Convert.ToInt16(DropDownGroup.SelectedItem.Value);
                                grp.UpdatedOn = DateTime.Now;
                                grp.UpdatedBy = Session["UserEmail"].ToString();
                                grp.userRole = DropdownUserrole.SelectedItem.Text;
                                // grp.Active = true;
                                objDB.SubmitChanges();
                                showOutputMessage((int)BLL.Constants.MessageType.Success, "User Updated Successully.");
                                System.Threading.Thread.Sleep(3000);
                            }
                            else
                            {
                                //Response.Write("<script>alert('This Email Already exist.')</script>");
                                showOutputMessage((int)BLL.Constants.MessageType.Fail, "This Email Already exist.");
                                return;
                                //Utilities.CreateMessageLabel(this, BLL.Constants.UnableToCreateGroup, false);
                            }

                        }
                    }
                }
                else
                {
                    if (!IsExistEmail(txtEmail.Text.Trim(), 0))
                    {
                        string temppass = CreateRandomPassword(6);
                        using (AccreditationDataContext registration = new AccreditationDataContext())
                        {
                            TblUserRegistration registration1 = new TblUserRegistration
                            {
                                UserFirstName = txtFirstName.Text.Trim(),
                                UserLastName = txtLastName.Text.Trim(),
                                UserEmail = txtEmail.Text.Trim(),
                                Group = Convert.ToInt16(DropDownGroup.SelectedItem.Value),
                                CreatedBy = Session["UserEmail"].ToString(),
                                CreatedOn = DateTime.Now,
                                Active = false,
                                userRole = DropdownUserrole.SelectedItem.Text,
                                TempPass = temppass,
                                HashPass = ""
                            };
                            registration.Connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings["constr"];
                            registration.TblUserRegistrations.InsertOnSubmit(registration1);
                            registration.SubmitChanges();
                            SendMail(txtEmail.Text.Trim(), txtFirstName.Text, temppass);
                            showOutputMessage((int)BLL.Constants.MessageType.Success, "User created Successully.");
                            System.Threading.Thread.Sleep(3000);
                        }
                    }
                    else
                    {
                        //Response.Write("<script>alert('This Email Already exist.')</script>");
                        showOutputMessage((int)BLL.Constants.MessageType.Fail, "This Email Already exist.");
                        return;
                        //Utilities.CreateMessageLabel(this, BLL.Constants.UnableToCreateGroup, false);
                    }
                } //--

            }

            Response.AddHeader("REFRESH", "5;URL=UserRegList.aspx");
               // Response.Redirect("UserRegList.aspx");
            return;
        }
		private void detach_TblUserRegistrations(TblUserRegistration entity)
		{
			this.SendPropertyChanging();
			entity.TblGroupCreation = null;
		}
 partial void UpdateTblUserRegistration(TblUserRegistration instance);
 partial void DeleteTblUserRegistration(TblUserRegistration instance);
 partial void InsertTblUserRegistration(TblUserRegistration instance);