/// <summary> /// Handles the Click event of the lnkAddCustomField control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param> protected void lnkAddCustomField_Click(object sender, EventArgs e) { var newName = txtName.Text.Trim(); if (newName == String.Empty) { return; } var dataType = (ValidationDataType)Enum.Parse(typeof(ValidationDataType), dropDataType.SelectedValue); var fieldType = (CustomFieldType)Enum.Parse(typeof(CustomFieldType), rblCustomFieldType.SelectedValue); var required = chkRequired.Checked; var newCustomField = new CustomField { ProjectId = ProjectId, Name = newName, DataType = dataType, Required = required, FieldType = fieldType }; if (CustomFieldManager.SaveOrUpdate(newCustomField)) { txtName.Text = ""; dropDataType.SelectedIndex = 0; chkRequired.Checked = false; BindCustomFields(); } else { lblError.Text = LoggingManager.GetErrorMessageResource("SaveCustomFieldError"); } }
/// <summary> /// Handles the Update event of the grdCustomFields control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param> protected void grdCustomFields_Update(object sender, DataGridCommandEventArgs e) { var cf = CustomFieldManager.GetById(Convert.ToInt32(grdCustomFields.DataKeys[e.Item.ItemIndex])); var txtCustomFieldName = (TextBox)e.Item.FindControl("txtCustomFieldName"); var customFieldType = (DropDownList)e.Item.FindControl("dropCustomFieldType"); var dataType = (DropDownList)e.Item.FindControl("dropEditDataType"); var required = (CheckBox)e.Item.FindControl("chkEditRequired"); cf.Name = txtCustomFieldName.Text; var DataType = (ValidationDataType)Enum.Parse(typeof(ValidationDataType), dataType.SelectedValue); var FieldType = (CustomFieldType)Enum.Parse(typeof(CustomFieldType), customFieldType.SelectedValue); cf.FieldType = FieldType; cf.DataType = DataType; cf.Required = required.Checked; CustomFieldManager.SaveOrUpdate(cf); grdCustomFields.EditItemIndex = -1; BindCustomFields(); }