Search code examples
c#ado.netdatasetdatarelation

How to display a DataRelation on DataGridView


5 and I try to solve the "more than one entity situation" using a single query for each one and then joined them with DataRelation, so after I realized that I've tryed to show data on this way :

DataColumn parentColumn = dataSet.Tables["Suppliers"].Columns["SupplierID"];
DataColumn childColumn = dataSet.Tables["Products"].Columns["SupplierID"];
DataRelation relation = new System.Data.DataRelation("SuppliersProducts", parentColumn, childColumn);
dataSet.Relations.Add(relation);
DataGridView1.DataSource = dataSet;

But it will not success cause each query result is on different DataTable, but in the same DataSet, so How can I show the "joined result"?

Thanks


Solution

  • DataGridView has not support relation table in one datagridview,, bind directly to related table instead, you must create 2 data grid parent and child and then show the result.