protected void dgEtFieldsAttributes_ItemCommand(Object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int attributeId; int tableId = int.Parse(ddlTableDefs.SelectedValue); string tableName = lblEtTableName.Text; MetadataNewDa MNDa = new MetadataNewDa(); switch (e.CommandName) { case "Delete": attributeId = int.Parse(e.Item.Cells[0].Text); MNDa.DeleteAttribute(attributeId); break; case "SaveAttributes": DataGrid dgAttributes = (DataGrid)source; foreach (DataGridItem dgi in dgAttributes.Items) { if (dgi.ItemType == ListItemType.Item || dgi.ItemType == ListItemType.AlternatingItem) { int fieldAttributeId = int.Parse(dgi.Cells[0].Text); DropDownList ddl = (DropDownList)dgi.FindControl("attDdlAttributeValue"); TextBox txt = (TextBox)dgi.FindControl("attTxtAttributeValue"); string theValue; if (((TextBox)dgi.FindControl("attTxtAttributeValueCtrlUsed")).Text == "txt") { theValue = txt.Text; } else { theValue = ddl.SelectedValue; } theValue = PageUtil.EscapeSingleQuotesForSql(theValue); MNDa.UpdateAttribute(fieldAttributeId, theValue); } } TextBox txtNewAttributesList = (TextBox)Page.FindControl("attTxtNewAttributesList"); string[] atts = txtNewAttributesList.Text.Split(char.Parse("@")); for (int k = 0; k < atts.Length; k++) { string[] anAtt = atts[k].Split(char.Parse(";")); if (anAtt.Length == 3 && PageUtil.IsInteger(anAtt[0]) && PageUtil.IsInteger(anAtt[1])) { string attValue = PageUtil.EscapeSingleQuotesForSql(anAtt[2]); MNDa.DeleteAttribute(int.Parse(anAtt[0]), int.Parse(anAtt[1])); MNDa.AddAttribute(int.Parse(anAtt[0]), int.Parse(anAtt[1]), attValue); } } txtNewAttributesList.Text = ""; break; } viewMode = "editTable"; setViewMode(); updateEditTableView(tableId, tableName); }