protected override void grid_RowCommand(object sender, GridViewCommandEventArgs e) { Button btn = e.CommandSource as Button; if (btn == null) { return; } GridViewRow row = btn.NamingContainer as GridViewRow; int rowIndex = row.RowIndex; if (e.CommandName.Equals("Copy")) { var newValues = this.GetValues(row); string origName = newValues[FIELDS[1]].ToString().Replace(" ", " "); origName = origName.Replace(" ", " "); string copyName = origName + "_COPY"; copyName = GetUniqueName("ProdDesc", "ProdID", "tblprodfore", copyName); { ClassA classA = new ClassA(GetDirectory() + userDir); classA.setGlobalVar(); string uniqueName = ""; try { uniqueName = classA.CopyProdFore(origName, copyName); } catch (Exception exp) { logFiles.ErrorLog(exp); SetData(); try { Master.HideLoadingPopup(); } catch (Exception) { } Master.ShowErrorMessage("There is invalid data in the Product file. Some information may not be copied."); return; } classA.Close(); tableSync.SyncTables(); tableSync.UpdateEquipNames(); tableSync.UpdateOperNames(); SetData(); if (!uniqueName.Equals("")) { try { SetData(); int id = int.Parse(GetId(uniqueName)); GoToEditMode(id); } catch (Exception) { } } } try { Master.HideLoadingPopup(); } catch (Exception) { } } else { base.grid_RowCommand(sender, e); } }