protected void AddButton_Click(object sender, System.EventArgs e) { PaymentMethod method = new PaymentMethod(); method.Name = Name.Text; method.PaymentInstrumentType = (PaymentInstrumentType)AlwaysConvert.ToInt16(PaymentInstrumentList.SelectedValue); method.PaymentGateway = PaymentGatewayDataSource.Load(AlwaysConvert.ToInt(GatewayList.SelectedValue)); method.AllowSubscriptions = AllowSubscriptionPayments.Checked; //GROUP RESTRICTION if (UseGroupRestriction.SelectedIndex > 0) { foreach (ListItem item in GroupList.Items) { Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { method.Groups.Add(group); } } } method.OrderBy = (short)PaymentMethodDataSource.GetNextOrderBy(); method.Save(); //UPDATE THE ADD MESSAGE AddedMessage.Text = string.Format(AddedMessage.Text, method.Name); AddedMessage.Visible = true; //RESET THE ADD FORM PaymentInstrumentList.SelectedIndex = -1; Name.Text = string.Empty; GatewayList.SelectedIndex = -1; AllowSubscriptionPayments.Checked = false; UseGroupRestriction.SelectedIndex = 0; BindGroups(); //TRIGER ANY EVENT ATTACHED TO THE UPDATE if (ItemAdded != null) { ItemAdded(this, new PersistentItemEventArgs(method.Id, method.Name)); } }