protected void btnSaveOrder_Click(object sender, EventArgs e) { int attributeId = Convert.ToInt32(hidAttributeId.Value); StringBuilder deleteErrors = new StringBuilder(); foreach (DataListItem item in dlAssociations.Items) { CheckBox chkObjectAssociation = item.FindControl("chkObjectAssociation") as CheckBox; DropDownList ddlObjectAttributeType = item.FindControl("ddlObjectAttributeType") as DropDownList; TextBox txtDescription = item.FindControl("txtDescription") as TextBox; TextBox txtDisplayLabel = item.FindControl("txtDisplayLabel") as TextBox; HiddenField hidObjectId = item.FindControl("hidObjectId") as HiddenField; if (chkObjectAssociation.Checked) { ObjectAttribute.SaveObjectAttribute(Objects.Single(x => { return(x.Value == chkObjectAssociation.Text); }).Key, attributeId, Convert.ToInt32(ddlObjectAttributeType.SelectedItem.Value), txtDescription.Text, txtDisplayLabel.Text); } else { try { ObjectAttribute.DeleteSingleObjectAttribute(Convert.ToInt32(hidObjectId.Value), attributeId); } catch (Exception ex) { deleteErrors.Append(chkObjectAssociation.Text + ":"); deleteErrors.Append(ex.Message); deleteErrors.Append("<br/>"); } } } if (deleteErrors.Length > 0) { ShowError(string.Format("Errors encountered while deleting object attribute associations for '{0}' (possibly due to values already existing): <br/>" + deleteErrors.ToString(), lblAttributeName.Text)); } else { ShowError(string.Empty); } mpePopup.Hide(); PopulateAttributes(); }