/// <summary> /// Save's dirty rows (new and existing) /// </summary> private void Save() { foreach (GridViewRow row in AttributesGrid.DirtyGridRows) { BOL.LookupAttribute biz = new LookupAttribute(); object attributeId = AttributesGrid.DataKeys[row.RowIndex][BOL.LookupAttribute.AttributeId]; if (attributeId != null && !string.IsNullOrEmpty(attributeId.ToString())) { biz.Get(int.Parse(attributeId.ToString())); } var attributeNameField = row.FindControl("AttributeName") as ICaisisInputControl; if (!string.IsNullOrEmpty(attributeNameField.Value)) { biz[BOL.LookupAttribute.AttributeName] = attributeNameField.Value; biz.Save(); } } }
/// <summary> /// Updates an existing LookupAttribute record, or inserts new record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void UpdateAttribute(object sender, EventArgs e) { CaisisTextBox attributeNameField = sender as CaisisTextBox; CaisisHidden attributeIdField = attributeNameField.NamingContainer.FindControl("AttributeId") as CaisisHidden; if (!string.IsNullOrEmpty(attributeNameField.Value)) { // don't inesrt empty attribut names LookupAttribute biz = new LookupAttribute(); // determine if updating or inserting if (attributeIdField != null && !string.IsNullOrEmpty(attributeIdField.Value)) { biz.Get(int.Parse(attributeIdField.Value)); } biz[LookupAttribute.AttributeName] = attributeNameField.Value; biz.Save(); } }