Data Selector for different databands
Hi,
So, I sit with the scenario where I have one form with a Data Selector and I choose a DataColum, let's (for ease of explaining) say it is the table 'Lecturer' and column 'Name', thus DataColumn would be Lecturer.Name
On page 1 of my report I have a databand which works on Lecturer, so here the data get's filtered correctly.
Also on page 1 I have another databand which works from Student, and the Student table has a LecturerId. How do I filter the data on the student table to only use the lecturers which were chosen in the Data Selector ?
Note the two bands are NOT child bands in any way, and they (or any one of the two) can't be made child band(s)
I also do not want to create another Data Selector and for the user to select twice, however, I am willing (if possible) to do this in the report's code.
Any help would be appreciated.
Comments
Hello!
If two DataBands (Lecturer and Student) are positioned independently (not as a master-detail ChildBand), and the DataSelector has filtered the first Lecturer band, you can filter the second Student band by the selected lecturers directly in the ReportScript without a second DataSelector:
private readonly HashSet<int> _selectedIds = new HashSet<int>(); private void DataLecturer_BeforePrint(object sender, EventArgs e) { _selectedIds.Add(Convert.ToInt32(Report.GetColumnValue(‘Lecturer.Id’))); } private void DataStudent_BeforePrint(object sender, EventArgs e) { int lid = Convert.ToInt32(Report.GetColumnValue(‘Student.LecturerId’)); DataStudent.Visible = _selectedIds.Contains(lid); }With this approach, when printing, DataLecturer collects the IDs of lecturers who have actually passed the filter, whilst DataStudent hides all student records whose LecturerId is not included in the selection.