[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 561
  • Last Modified:

Datagrid bind problem - Cannot create a child list (C# / windows.net)

I am working on a windows.net application and having problem binding to a datagrid.  I believe it has something to do a child relationship, if so, how can I remove the relationship before binding?  

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Cannot create a child list for field tblEquipmentInventory.

//Initalize dataset.
  this.ds.Clear();
  this.ds.AcceptChanges();
//Get data from tables tblEquipmentInventory, facility, customer...)                               
  this.ds = this.bizObj.FilterByScenario(this.dsCustomer, this.lbscenario.Text.ToString(), nchCustomerID.ToString());
  string expression = "EquipmentColA = 1";
  DataView dv = ds.Tables["tblEquipmentInventory"].DefaultView;
//Only get rows ColA = 1
  dv.RowFilter = expression;
  this.dgEquipment.DataSource = dv;
//Bind to datagrid
   this.dgEquipment.SetDataBinding(dv, "tblEquipmentInventory")
0
Hojoformo
Asked:
Hojoformo
  • 2
  • 2
2 Solutions
 
dunglaCommented:
Hi Hojoformo,

Which line thru this exception?
0
 
dunglaCommented:
Hi there,

Try to remove this line:

//Bind to datagrid
   this.dgEquipment.SetDataBinding(dv, "tblEquipmentInventory");
0
 
HojoformoAuthor Commented:
that was it.  interesting, can not bind dataviews to a grid.  I do not understand but it works.
0
 
anyoneisCommented:
>  interesting, can not bind dataviews to a grid

Yes, you can, but the SetDataBinding arguments are (DataSource, DataMember). and tblEquipmentInventory is not a valid member of it's own default view.

David
0
 
anyoneisCommented:
You could have used:
//Bind to datagrid
   this.dgEquipment.SetDataBinding(dv, "");

I think.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now