Solved

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

Posted on 2006-10-26
5
550 Views
Last Modified: 2008-02-01
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
Comment
Question by:Hojoformo
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:dungla
ID: 17816843
Hi Hojoformo,

Which line thru this exception?
0
 
LVL 13

Accepted Solution

by:
dungla earned 400 total points
ID: 17816855
Hi there,

Try to remove this line:

//Bind to datagrid
   this.dgEquipment.SetDataBinding(dv, "tblEquipmentInventory");
0
 

Author Comment

by:Hojoformo
ID: 17818393
that was it.  interesting, can not bind dataviews to a grid.  I do not understand but it works.
0
 
LVL 11

Expert Comment

by:anyoneis
ID: 17824921
>  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
 
LVL 11

Assisted Solution

by:anyoneis
anyoneis earned 100 total points
ID: 17824935
You could have used:
//Bind to datagrid
   this.dgEquipment.SetDataBinding(dv, "");

I think.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question