Help creating Databand filter at run-time

Stimulsoft Reports.NET discussion
Post Reply
fuhrj
Posts: 120
Joined: Wed Jun 11, 2008 12:51 pm
Location: Lancaster, Ohio

Help creating Databand filter at run-time

Post by fuhrj »

In my report, I have a drop-down list with a list of employees plus an option "All Users". Because of the "All" option, I can't hardcode the filter in the Databand so I am trying to create a filter at runtime.


In the report form, I have a button with an onclick event:

Code: Select all


if (userID > 0) {
	StiFilter userFilter = new StiFilter("ReportData.userID == " + userID.ToString());
	Data1.Filters.Add(userFilter);	
}

ReportData.Connect();

fuhrj
Posts: 120
Joined: Wed Jun 11, 2008 12:51 pm
Location: Lancaster, Ohio

Help creating Databand filter at run-time

Post by fuhrj »

Okay, I figured a way to make this work.

I created a variable to hold the value of the list item selected in the form.

On the Databand, I created this filter expression:

Code: Select all

ReportData.userID == ((varUser == 0) ? ReportData.userID : varUser)
If the user chooses "All Users" then varUser is set to 0. The expression checks the value of varUser and if it is 0, it uses the current userID. So the expression becomes ReportData.userID == ReportData.userID which will always evaluate true and the record will be used.
Post Reply