private void Delete(int DeleteID)
 {
     ProfileManagementController objController = new ProfileManagementController();
     objController.DeleteProfileValueByProfileID(DeleteID, GetPortalID, GetUsername);
     objController.DeleteProfileByProfileID(DeleteID, GetUsername);
     RefreshGrid();
     ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "ProfileDeletedSuccessfully"), "", SageMessageType.Success);
 }
 private void SaveProfileDefination()
 {
     try
     {
         if (ValidateProfilepropertyForm())
         {
             if (Session[SessionKeys.EditProfileID] != null)
             {
                 int PropertyTypeID = Int32.Parse(ddlPropertyType.SelectedValue);
                 int ProfileID = Int32.Parse(Session[SessionKeys.EditProfileID].ToString());
                 ProfileManagementController objController = new ProfileManagementController();
                 if (ProfileID != 0)
                 {
                     objController.UpdateProfile(ProfileID, txtCaption.Text.Trim(), PropertyTypeID, ddlDataType.SelectedItem.Value, chkIsRequred.Checked, true, true, DateTime.Now, GetPortalID, GetUsername);
                     if (ProfileID != 0 && PropertyTypeID != 1 && PropertyTypeID != 5 && PropertyTypeID != 6 && PropertyTypeID != 7 && PropertyTypeID != 8 && lstvPropertyValue.Items.Count > 0)
                     {                                
                         objController.DeleteProfileValueByProfileID(ProfileID, GetPortalID, GetUsername);
                         for (int i = 0; i < lstvPropertyValue.Items.Count; i++)
                         {
                             int ProfileValueID = 0;
                             ProfileValueID = objController.AddProfileValue(ProfileID, lstvPropertyValue.Items[i].Text, true, DateTime.Now, GetPortalID, GetUsername);
                         }
                     }
                     ShowMessage("", GetSageMessage("UserManagement", "ProfileUpdatedSuccessfully"), "", SageMessageType.Success);
                     ClearProfilepropertyForm();
                     RefreshGrid();
                 }
             }
             else
             {
                 ProfileManagementController objController = new ProfileManagementController();
                 int PropertyTypeID = Int32.Parse(ddlPropertyType.SelectedValue);
                 int ProfileID = 0;
                 ProfileID = objController.AddProfile(txtCaption.Text.Trim(), PropertyTypeID, ddlDataType.SelectedItem.Value, chkIsRequred.Checked, true, DateTime.Now, GetPortalID, GetUsername);
                 if (ProfileID != 0 && PropertyTypeID != 1 && PropertyTypeID != 5 && PropertyTypeID != 6 && PropertyTypeID != 7 && PropertyTypeID != 8 && lstvPropertyValue.Items.Count > 0)
                 {
                     for (int i = 0; i < lstvPropertyValue.Items.Count; i++)
                     {
                         int ProfileValueID = 0;
                         ProfileValueID = objController.AddProfileValue(ProfileID, lstvPropertyValue.Items[i].Text, true, DateTime.Now, GetPortalID, GetUsername);
                     }
                 }
                 ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("UserManagement", "ProfileAddedSuccessfully"), "", SageMessageType.Success);
                 ClearProfilepropertyForm();
                 RefreshGrid();
             }
         }
         else
         {
             ShowMessage(SageMessageTitle.Information.ToString(), strMessage.ToString(), "", SageMessageType.Success);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }