Resolving datasource object type on bands
danni
Denmark
hi
I use the current method to discover the type of datasource on bands:
Can you tell me why this does not work before datasource is set?
I use the list<string> of types to determin shich data should be loaded for the report.
Thanks.
I use the current method to discover the type of datasource on bands:
private List<String> ResolveDataSources(Report report)
        {
              List<String> list = new List<String>();
              foreach (PageBase pb in report.Pages)
              {
                 Â
                  foreach (var obj in pb.AllObjects)
                  {
                      if (obj is FastReport.DataBand)
                      {
                          if ((obj as FastReport.DataBand).DataSource != null &&
                              (obj as FastReport.DataBand).DataSource.DataType != null)
                              list.Add((obj as FastReport.DataBand).DataSource.DataType.GetGenericArguments()[0].Name);
                      }
                  }
              }
            return list;
        }
Can you tell me why this does not work before datasource is set?
I use the list<string> of types to determin shich data should be loaded for the report.
Thanks.
Comments
Can this be correct? (I can see the type after data is registered, but then it is too late)
I am missing the datatype value in order to minimize the number of calls to the database when I fetch data for the report.
This code works well for me if I insert in in the Features/Business Objects demo report:
The _StartReport event handler is connected to the Report.StartReport.
It seems start is fired when datasource is bound the first time? I would like to know the types before retrieving data from my server environment.
I have modified my example it a bit, so it works as I would like it to do.
It is a bit of a hack because I register an empty datasource, then resolve types from the bands.
Now I can reduce the Loading of data with the resolved types from the bands, Meaning I only fetch data needed to preview the report. Awsome!