I have a large dataset that load in with a fill method on page load.
Then, a record can be added to the dataset.
All of that works fine, but the only way that I can get the bindingsource to recognize the new record is to do a fill method. This also works but is a perfomance problem. Why does the binding source not see the new record in the dataset?
Mainform Code. Works Great.
DialogResult returnFormVal;
Schedulers.DataSets.SchedOneFetch.WOMainFetchRow newRow = schedOneFetch.WOMainFetch.NewWOMainFetchRow();
Schedulers.Forms.NewWorkOrder genReport = new Schedulers.Forms.NewWorkOrder(ref newRow);
Int32 picNumber;
returnFormVal = genReport.ShowDialog();
schedOneFetch.WOMainFetch.Rows.Add(newRow);
wOMainFetchBindingSource.EndEdit();
wOMainFetchTableAdapter.Adapter.Update(schedOneFetch.WOMainFetch);
Int32 passBackVal = newRow.DISID;
SubForm code. Also works great.
passBackRow.DISDueDate = monthCalendar1.SelectionStart;
passBackRow.DISID = 99999999;
if (ckbEqpt.Checked == true & lbProcNum.Items.Count > 0)
{
passBackRow.DISEquip = Convert.ToInt32(lbProcNum.SelectedValue.ToString());
}
else
{
passBackRow.DISEquip = 0;
}
passBackRow.DISLineNumber = Convert.ToInt32(lbLineName.SelectedValue.ToString());
passBackRow.DISManHours = Convert.ToInt32(nudEstTotTime.Value);
passBackRow.DISNumberAss = Convert.ToInt32(nudEstTM.Value);
passBackRow.DISOpenDate = DateTime.Now;
passBackRow.DISOriginator = userID.DBUserID;
passBackRow.DISRequestor = 0;
passBackRow.DISResponsible = Convert.ToInt32(lbRespons.SelectedValue.ToString());
passBackRow.DISType = Convert.ToInt32(lbType.SelectedValue.ToString());
passBackRow.DISWorkAccomp = "";
passBackRow.DISWorkRequired = rtbWorkReq.Text;
passBackRow.MLID = 0;
passBackRow.LIID = 0;
passBackVal = 0;
this.Close();
Return control to main form. The new record has been added to the database.
wOMainFetchBindingSource.Position = wOMainFetchBindingSource.Find("DISID", passBackVal);
DataRowView dtaRow = (DataRowView)wOMainFetchBindingSource.Current;
String woID = dtaRow["DISID"].ToString();
FAIL! The bindingsource wont find the the new record, returns a -1 on the find and defaults to the first record in the dataset.
If I put the .fill method in between the dialog and the main page then it all works fine, but takes a loooonnng time to do the fill... seven or eight seconds.
I guess my understanding of the binding source is disfunctional, I had assumed that if the underlying dataset was updated then the bindingsource would see it.
So, first if someone has a suggestion on how to refresh the binding source without the fill I would appreciate it, and if someone can explain why this works the way it does I might be able to find a workaround.
Thanks