protected void Name_OnUpdate(object sender, DataGridCommandEventArgs e) { Page.Validate(); if (Page.IsValid) { int index = grid.EditItemIndex; DataGridItem item = grid.Items[index]; if (index >= names.Count) { names.Add(""); } Name name = names[index]; name.IsoLangCode = ((DropDownList)item.FindControl("language")).SelectedItem.Value; name.Value = ((TextBox)item.FindControl("name")).Text.Trim(); CheckBox checkbox = (CheckBox)item.FindControl("default"); if (index > 0 && null != checkbox && checkbox.Checked) { for (int i = index; i > 0; i--) { names[i] = names[i - 1]; } names[0] = name; index = 0; } parentEntity.Save(); if (0 == index && !IsDownlevel) { Page.RegisterStartupScript( "Reload", ClientScripts.ReloadExplorerPane( parentKey)); } grid.EditItemIndex = -1; CancelEditMode(); PopulateDataGrid(); } }
protected void Name_OnDelete(object sender, DataGridCommandEventArgs e) { int index = e.Item.ItemIndex; names.RemoveAt(index); parentEntity.Save(); PopulateDataGrid(); if (0 == index && !IsDownlevel) { Page.RegisterStartupScript( "Reload", ClientScripts.ReloadExplorerPane( parentKey)); } }