private void btn_editSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_settingSaveName.Text)) { MessageBox.Show("Setting Name Required"); return; } ABSetting setting = GetSettingsFromForm(); if (grd_settingsList.SelectedRows.Count > 0) { object pkId = grd_settingsList.SelectedRows[0].Cells["PkId"].Value; setting.PkId = Convert.ToInt32(pkId); SettingDAL.UpdateSetting(setting); } else { SettingDAL.SaveSetting(setting); } SettingList_Load(sender, e); HideSettingForm(); }