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

Comments

  • edited 2:55AM
    Hello,

    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>

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.