コード例 #1
0
        //Adding a New Record here
        private void dataGridView1_RowLeave(object sender, DataGridViewCellEventArgs e)
        {
            string studentId = dataGridView1.CurrentRow.Cells["StudentId"].Value.ToString();

            if (studentId.Equals(string.Empty))
            {
                StudentBO objStudentBO = new StudentBO();

                try
                {
                    objStudentBO.RollNumber = dataGridView1.CurrentRow.Cells["RollNumber"].Value.ToString();
                    objStudentBO.FirstName  = dataGridView1.CurrentRow.Cells["FirstName"].Value.ToString();
                    objStudentBO.LastName   = dataGridView1.CurrentRow.Cells["LastName"].Value.ToString();
                    objStudentBO.Gender     = dataGridView1.CurrentRow.Cells["Gender"].Value.ToString();
                    objStudentBO.Stream     = dataGridView1.CurrentRow.Cells["Stream"].Value.ToString();

                    StudentBL.AddNewStudentDetails(objStudentBO);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }