G
Gerard
Hi
I am trying to do a 1 to many relationship using dynamic textboxes,
binding navigator and a filter. It works on form_load but when i
change to the next row on the bindingNavigator I get.
"Object reference not set to an instance of an object."
Here is the code:
DataRowView view =
(DataRowView)tBLSitesBindingSource.Current;
// crashes current = null;
string companyID = view.Row["companyID"].ToString();
// crashes here after position change in bindingnav
tBLSitesBindingSource.Filter = "companyID = " + companyID;
for (int i = 0; i < rowCount; i++)
{
TextBox tb = new TextBox();
tb.DataBindings.Add(new
System.Windows.Forms.Binding("Text", tBLSitesBindingSource,
"siteName", true));
manyVertPos = manyVertPos + 40;
tb.Location = new System.Drawing.Point(5,
manyVertPos);
tb.Name = "ManyTxtBox" + i;
tb.Size = new System.Drawing.Size(178, 20);
this.Controls.Add(tb);
GRPSites.Controls.Add(tb);
}
Is this an acceptible way of doing a 1 to many relationship or am I
barking up the wrong tree.
Cheers
I am trying to do a 1 to many relationship using dynamic textboxes,
binding navigator and a filter. It works on form_load but when i
change to the next row on the bindingNavigator I get.
"Object reference not set to an instance of an object."
Here is the code:
DataRowView view =
(DataRowView)tBLSitesBindingSource.Current;
// crashes current = null;
string companyID = view.Row["companyID"].ToString();
// crashes here after position change in bindingnav
tBLSitesBindingSource.Filter = "companyID = " + companyID;
for (int i = 0; i < rowCount; i++)
{
TextBox tb = new TextBox();
tb.DataBindings.Add(new
System.Windows.Forms.Binding("Text", tBLSitesBindingSource,
"siteName", true));
manyVertPos = manyVertPos + 40;
tb.Location = new System.Drawing.Point(5,
manyVertPos);
tb.Name = "ManyTxtBox" + i;
tb.Size = new System.Drawing.Size(178, 20);
this.Controls.Add(tb);
GRPSites.Controls.Add(tb);
}
Is this an acceptible way of doing a 1 to many relationship or am I
barking up the wrong tree.
Cheers