//Submit Add Form
        protected void AddPatientButton_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;
            String btnId = btn.ID;

            if (btnId.Equals("AddPatientButton"))
            {
                if (IsValid)
                {
                    System.Threading.Thread.Sleep(3000);
                    var name = NameTextBox.Text;
                    var gender = GenderRadioButtonList1.SelectedItem.Value;
                    var genderId = long.Parse(gender);
                    var dob = Convert.ToDateTime(DOBTextBox.Text);
                    var address = AddressTextBox.Text;

                    var patient = new Patient() { patientName = name, genderId = genderId, dob = dob, address = address };
                    _dataContext.Patients.InsertOnSubmit(patient);
                    _dataContext.SubmitChanges();
                    PatientsList.DataBind();

                    ResetInputField();

                    //Use For checking Data
                    //Debug.WriteLine("name: " + name);
                    //Debug.WriteLine("gender: " + gender);
                    //Debug.WriteLine("dob: " + dob);
                    //Debug.WriteLine("address: " + address);
                }
                else if (btnId.Equals("ResetPatientButton"))
                {
                    ResetInputField();
                }
            }
        }
        //Update Button Control
        protected void UpdateButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                System.Threading.Thread.Sleep(3000);
                Label lblId = FormView1.FindControl("EditId") as Label;
                var id = long.Parse(lblId.Text);
                TextBox txtBoxName = FormView1.FindControl("EditName") as TextBox;
                var name = txtBoxName.Text;
                Label txtBoxGender = FormView1.FindControl("EditGender") as Label;
                var gender = (txtBoxGender.Text.Equals("Male")) ? 1 : 2;
                TextBox txtBoxDOB = FormView1.FindControl("EditDOB") as TextBox;
                var dob = Convert.ToDateTime(txtBoxDOB.Text);
                TextBox txtBoxAddress = FormView1.FindControl("EditAddress") as TextBox;
                var address = txtBoxAddress.Text;

                var patient = new Patient() { patientId = id, patientName = name, genderId = gender, dob = dob, address = address };
                _dataContext.Patients.Attach(patient);
                _dataContext.Refresh(RefreshMode.KeepCurrentValues, patient);
                _dataContext.SubmitChanges();
                //Use For Debug passed value
                //Debug.WriteLine("id: " + id);
                //Debug.WriteLine("groupId: " + groupId);
                //Debug.WriteLine("Name: " + name);
                //Debug.WriteLine("price: " + price);
            }
        }
 partial void DeletePatient(Patient instance);
 partial void UpdatePatient(Patient instance);
 partial void InsertPatient(Patient instance);
		private void detach_Patients(Patient entity)
		{
			this.SendPropertyChanging();
			entity.Gender = null;
		}
		private void attach_Patients(Patient entity)
		{
			this.SendPropertyChanging();
			entity.Gender = this;
		}
        //Control Update Process
        protected void UpdateButton_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                System.Threading.Thread.Sleep(3000);
                var editedRowIndex = PatientsList.EditIndex;
                var lblId = PatientsList.Rows[editedRowIndex].FindControl("EditId") as Label;
                var txtBName = PatientsList.Rows[editedRowIndex].FindControl("EditName") as TextBox;
                var txtBGender = PatientsList.Rows[editedRowIndex].FindControl("EditGender") as Label;
                var txtBDob = PatientsList.Rows[editedRowIndex].FindControl("EditDOBTextBox") as TextBox;
                var txtBAddress = PatientsList.Rows[editedRowIndex].FindControl("EditAddress") as TextBox;

                var id = long.Parse(lblId.Text);
                var name = txtBName.Text;
                var gender = (txtBGender.Text.Equals("Male")) ? 1 : 2;
                var dob = Convert.ToDateTime(txtBDob.Text);
                var address = txtBAddress.Text;

                var patient = new Patient() { patientId = id, patientName = name, genderId = gender, dob = dob, address = address };
                _dataContext.Patients.Attach(patient);
                _dataContext.Refresh(RefreshMode.KeepCurrentValues, patient);
                _dataContext.SubmitChanges();
                PatientsList.EditIndex = -1;

                //Use For Debug passed value
                //Debug.WriteLine("id: " + id);
                //Debug.WriteLine("name: " + name);
                //Debug.WriteLine("gender: " + gender);
                //Debug.WriteLine("dob: " + dob);
                //Debug.WriteLine("address: " + address);
            }
        }