private void dataGridFoodMenus_SelectionChanged(object sender, EventArgs e) { if (dataGridFoodMenus.RowCount > 0) { try { //keeps track of what row is selected for editing their record int selectedMenuId = Convert.ToInt32(dataGridFoodMenus.CurrentRow.Cells[0].Value); FoodMenu selectedMenu = FoodMenu.RetrieveById(selectedMenuId); txtMenuId.Text = selectedMenu.ID.ToString(); txtMenuMeat.Text = selectedMenu.Meat; txtMenuVeg1.Text = selectedMenu.Vegetable_1; txtMenuVeg2.Text = selectedMenu.Vegetable_2; txtMenuDrink.Text = selectedMenu.Drink; txtMenuPrice.Text = selectedMenu.Price.ToString(); } catch { //should never happen Console.WriteLine("ERROR: Cannot convert current row[0] to int32"); } } }