Hey Otis,
Thanks for your quick response. Well, actually, the binding 7000 rows to my control isn't as bad as you might think (it's not particularly quick, but it's not too slow either). The real problem seems to be creating and destroying the databindings each time the active (selected) entity changes.
I seem to have to do this for the controls to recognize that the data has changed.
Here's an example of the code that's killing me:
private void bindStudentMedical()
{
//
// Medical Tab
//
txtMedicalNotes.DataBindings.Clear();
txtMedicalNotes.DataBindings.Add("Text", theStudent, "MedicalInfo.MedicalNotes");
txtMedicalArrangements.DataBindings.Clear();
txtMedicalArrangements.DataBindings.Add("Text", theStudent, "MedicalInfo.Arrangements");
txtPhysician.DataBindings.Clear();
txtPhysician.DataBindings.Add("Text", theStudent, "MedicalInfo.Physician");
txtPhysicianPhone.DataBindings.Clear();
txtPhysicianPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.PhysicianPhone");
txtInsurance.DataBindings.Clear();
txtInsurance.DataBindings.Add("Text", theStudent, "MedicalInfo.InsuranceCompany");
txtInsurancePolicyNum.DataBindings.Clear();
txtInsurancePolicyNum.DataBindings.Add("Text", theStudent, "MedicalInfo.InsurancePolicy");
chkDisease.DataBindings.Clear();
chkDisease.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalDisease");
chkAllergies.DataBindings.Clear();
chkAllergies.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalAllergies");
chkMedication.DataBindings.Clear();
chkMedication.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalMedicationAllergies");
chkOngoing.DataBindings.Clear();
chkOngoing.DataBindings.Add("Checked", theStudent, "MedicalInfo.MedicalOngoing");
txtEmergencyName.DataBindings.Clear();
txtEmergencyName.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyContact");
txtEmergencyAddress.DataBindings.Clear();
txtEmergencyAddress.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyAddress1");
txtEmergencyCity.DataBindings.Clear();
txtEmergencyCity.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyCity");
txtEmergencyState.DataBindings.Clear();
txtEmergencyState.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyState");
txtEmergencyPostal.DataBindings.Clear();
txtEmergencyPostal.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyPostal");
txtEmergencyHomePhone.DataBindings.Clear();
txtEmergencyHomePhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyHomePhone");
txtEmergencyWorkPhone.DataBindings.Clear();
txtEmergencyWorkPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyWorkPhone");
txtEmergencyPagerPhone.DataBindings.Clear();
txtEmergencyPagerPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyCellPhone");
txtEmergencyCellPhone.DataBindings.Clear();
txtEmergencyCellPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyPagerPhone");
txtEmergencyOtherPhone.DataBindings.Clear();
txtEmergencyOtherPhone.DataBindings.Add("Text", theStudent, "MedicalInfo.EmergencyOtherPhone");
}
Here's what calls it (bindStudent calls a function that depends on the active tab rather than binding the controls for all the tabs--this helped):
private void studentControl1_SelectedValueChanged(object sender, EventArgs e)
{
if(studentControl1.SelectedIndex != -1)
{
// this student/tab is already bound, so skip rebinding
if (theStudent!=null)
if (((int)studentControl1.SelectedValue == boundStudentId) && (boundTab==tabStudents.SelectedIndex))
return;
theStudent = new StudentsEntity((int)studentControl1.SelectedValue);
bindStudent();
}
}
I tried to use something like:
theStudent.FetchUsingUCStudentId((int)studentControl1.SelectedValue);
rather than creating a new entity that I have to rebind to. But none of the controls updated to reflect the new data.
I've attached the complete code file for reference.