From 5b286c49306c390ccffa14bbcf3ce1b6408dd8ca Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Fri, 22 Jan 2021 20:33:01 -0800 Subject: [PATCH] Bugfix correct child_id from datagridview. --- frmAdminForm.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frmAdminForm.cs b/frmAdminForm.cs index 3bdbcb2..2d33c96 100644 --- a/frmAdminForm.cs +++ b/frmAdminForm.cs @@ -78,11 +78,11 @@ namespace GreatHomeChildcare //PB&J: get currently selected row from dgv, then pass to GetChildByID() to get Child object. private void btnUpdate_Click(object sender, EventArgs e) { - child_id = dgvChildren.CurrentRow.Index; - - //child_id must be incremented as the index starts at 0. - //TODO: FIX BUG!! - child_id++; + /* Get the child's database ID which is secretly hidden + * in the datagrid view at column 0. Since value is an + * Object, cast it to Int because that's what we know it is. + */ + child_id = (int)dgvChildren.CurrentRow.Cells[0].Value; ShowChildCrudForm(); }