DataRelation
Can anyone share some sample c# code to show how to relate to datatables.
I can do it in the designer but i need to register the data tables dynamically at runtime and just cant find how to setup the relationship
thanks
I can do it in the designer but i need to register the data tables dynamically at runtime and just cant find how to setup the relationship
thanks
Comments
The sample can be found in the class reference, the "Relation" class:
/// <summary>
/// Represents a master-detail relation between two data sources.
/// </summary>
/// <remarks>
/// To setup a relation, you must specify parent and child datasources. For a parent datasource,
/// you must specify set of key columns; for child datasource, you must specify set of columns that
/// relate to the parent key columns.
/// <example>This example shows how to create relation between Customers and Orders tables:
/// <code>
/// Report report1;
/// DataSourceBase customersTable = report1.Dictionary.DataSources.FindByAlias("Customers");
/// DataSourceBase ordersTable = report1.Dictionary.DataSources.FindByAlias("Orders");
/// Relation rel = new Relation();
/// rel.Name = "customersOrders";
/// rel.ParentDataSource = customersTable;
/// rel.ChildDataSource = ordersTable;
/// rel.ParentColumns = new string[] { "CustomerID" };
/// rel.ParentColumns = new string[] { "CustomerID" };
/// report1.Dictionary.Relations.Add(rel);
/// </code>
/// </example>
/// </remarks>