private void btnUpdate_Click(object sender, EventArgs e) { if (!ValidData(false)) { return; } int rowIndex = dgvCategoryList.CurrentCell.RowIndex; CategoryDTO category = new CategoryDTO { Name = txtName.Text, ID = int.Parse(dtCategories.Rows[rowIndex]["ID"].ToString()) }; if (MessageBox.Show("Do you want to Update Category-" + dtCategories.Rows[rowIndex]["Name"].ToString() + "?", "Update Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (categoryBUS.UpdateCategory(category)) { MessageBox.Show("Update category was successfull!", "Update Result", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); } else { MessageBox.Show("Update category was fail!", "Update Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }