private void btnUpdate_Click(object sender, EventArgs e) { var election = new Election(); election.ElectionId = txtElectionId.Text.Trim().ToUpper(); election.Post = txtElectionPost.Text.Trim().ToUpper(); election.NoOfCandidates = Convert.ToInt32(cmbNoOfCandidates.Text); election.StartDate = dtStartDate.Value; election.EndDate = dtEndDate.Value; var rowAffected = AddNewElection.UpdateElection(election); if (rowAffected > 0) { MessageBox.Show(@"Record updated successfully"); txtElectionId.Clear(); txtElectionPost.Clear(); btnSubmit.Enabled = true; btnDelete.Enabled = false; btnUpdate.Enabled = false; btnView_Click(null, null); cmbNoOfCandidates.SelectedIndex = -1; } else { MessageBox.Show(@"Record not updated successfully"); } }