Filter data by code

mohanarajmohanaraj 600001
edited January 2010 in FastReport .NET
Hello

I want to filter the data in the data source which i was registered to the report , in the collection i want to filter only the data which parentId = 0 i use the below code but it throw an error whats wrong in this ?

dataBand.DataSource = FReport.GetDataSource("dtorgSummary");
dataBand.Filter = "[dtOrgsummary.ParentId] == 0 ";


and also How to create the relation for the report datasource

Relation relationForDept = new Relation();
relationForDept.Name = "dtOrgsummary_dtOrgDeptsummary";
relationForDept.ReferenceName = "Data.dtOrgsummary_dtOrgDeptsummary";
relationForDept.ParentDataSource = "dtOrgsummary";
relationForDept.ChildDataSource = "dtOrgDeptsummary";
relationForDept.ParentColumns = "DepartmentId";
relationForDept.ChildColumns = "DepartmentId";
relationForDept.Enabled = "true";

how add this relation to the report?

thanks,

Comments

  • edited 4:26AM
    Hello,

    What error do you get?

    Please see the Class Reference on "Relation" class. It has an example on how to add a relation:

    /// 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);

Leave a Comment