I have a windows application. When I select the option one from a combo-box, I bind an UltraGrid control to a DataSet with to DataTables (Maestro and Detalle) and a Relation between them: ds_MaestroDetalle.Relations.Add( "Maestro_Detalle", ds_MaestroDetalle.Tables["Maestro"].Columns["ID"], ds_MaestroDetalle.Tables["Detalle"].Columns["ID"]);Since I want to Export to Excel the info in the two DataTables and the relationship, I use SetDataBindings: this.ug_Reportes.SetDataBinding(ds_MaestroDetalle, "Maestro");Then, when I select the option two from the combo-box, I bind the sameUltragrid to a DataTable. dt_MyTable.TableName = "Maestro"; this.ug_Reportes.DataSource = dt_MyTable;I get the following message when binding to the second option: "Child list for field Maestro cannot be created."I guess, when binding to the DataTable in the second option, UltraGrid is currently looking for Table Maestro in the DataSet (first option).I try to UltraGrid.DataBindings.Clear(), UltraGrid.DataSource = null, but I don't know how to reset UltraGrid to start binding again without problems.Thanks in advanced!
Thanks joshusch, I don't know how but you kind of gave me an idea of how to bypass an error I was getting from the compiler.
I'm using 2 tables and when trying to write something on my 2nd table I got this error message. Here's part of the code I was using:
connect=new OleDbConnection(ruta); connect.Open(); adapt=new OleDbDataAdapter(ins,connect); adapt.Fill(dataSet1,"Table2"); dataGridView1.DataMember="Table2"; dataGridView1.DataSource=dataSet1; connect.Close();
What I did was to change values from Table2 to Table1 which is my main table. Like this:
connect=new OleDbConnection(ruta); connect.Open(); adapt=new OleDbDataAdapter(ins,connect); adapt.Fill(dataSet1,"Table1"); dataGridView1.DataMember="Table1"; dataGridView1.DataSource=dataSet1; connect.Close();
I suspect the original poster has resolved his or her problem many months ago, but I wanted to explain what I found when I ran into the same error recently, so that others who search for the error might not spend as much time looking for an answer (or figuring it out themselves as I did).
In my case, I had created an UltraCombo and an UltraDataSource (for defining the columns at design time). I set the DataSource property of the combo to the UltraDataSource, and I set the DataMember property to the first (and only) band. The problem came when, at runtime, I tried binding the combo to a DataTable. That's what produced the error "Child list for field <DataMember> cannot be created."
There are 2 solutions. A) At runtime, bind the combo to a DataSet that contains your appropriately-named DataTable instead of just a DataTable. B) Leave the DataMember property blank on the combo at design time and keep binding directly to your DataTable.
Hope this saves a few people some time...
It's a little hard to tell what's happening here from your description.
What is dt_MyTable in code snippets you listed here? Why are you changing the table name?
Can you post the call stack of the error? The error message seems to indicate that something is asking the BindingManager for a particular child relation that does not exist.
Hello Michael
Did you mean this?
this.ug_Reportes.SetDataBinding(dt_MyTable, "Maestro");
Still having the same error message.
The problem seems to be that the DataMember is still looking for the table in the previous datasource. I believe you should call the SetDataBinding method again and set the DataSource and DataMember in one operation. Let me know if that works.
Michael S.