private void showCategoryGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (showCategoryGridView.Columns[e.ColumnIndex].Name == "UpdateButton") { categoryTextBox.Text = showCategoryGridView.Rows[e.RowIndex].Cells[2].Value.ToString(); updateId = Convert.ToInt32(showCategoryGridView.Rows[e.RowIndex].Cells[1].Value); UpdateButton2.Visible = true; } if (showCategoryGridView.Columns[e.ColumnIndex].Name == "DeleteButton") { if (DialogResult.Yes == MessageBox.Show("Do You Want Delete ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { updateId = Convert.ToInt32(showCategoryGridView.Rows[e.RowIndex].Cells[1].Value); int isSaved = categoryManage.DeleteCategory(updateId); if (isSaved > 0) { ShowAllData(); categoryTextBox.Clear(); } else { MessageBox.Show("Something Wrong into Database"); } } } }