To filter data in a report, doubleclick the "Data" band and switch to "Filter" tab. You can write any valid .Net expression here.
For example, in the "Simple List" report you can write the following expression to display employees which name starts with "A":
To filter data in a report, doubleclick the "Data" band and switch to "Filter" tab. You can write any valid .Net expression here.
For example, in the "Simple List" report you can write the following expression to display employees which name starts with "A":
[Employees.FirstName].StartsWith("A")
if , you put an example in my program creates an order for sale, save, and I've put a button "preview", which is supposed to receive and filter the code of the order for sale, and that makes the second Preview
- for saying he created the "order of sale number 350 and I want to print it alone, with the format that I designed, of course that such an order covering the entire sheet.
You can define a parameter in your report. To do this:
- go "Data" window. If it is not visible, you can view it in the "Data|Show Data Window" menu;
- click "Actions" button in the "Data" window. Select "New Parameter" item;
- go "Properties" window and set up the DataType and Name properties for the parameter. The DataType property is very important, set it properly.
To set the parameter in your application:
report1.SetParameter("myparam", value_for_param);
To use the parameter in the data filter:
- set the data band filter to something like this:
[Employee.FirstName] == [myparam]
You can define a parameter in your report. To do this:
- go "Data" window. If it is not visible, you can view it in the "Data|Show Data Window" menu;
- click "Actions" button in the "Data" window. Select "New Parameter" item;
- go "Properties" window and set up the DataType and Name properties for the parameter. The DataType property is very important, set it properly.
To set the parameter in your application:
report1.SetParameter("myparam", value_for_param);
To use the parameter in the data filter:
- set the data band filter to something like this:
[Employee.FirstName] == [myparam]
Yes, it's working fine but for small amount of data. What about setting parameter in a where clause? How to do it with some dialog form?
In this example:
- use the in-report datasources (created in the "Data|Add New Data Source..." menu);
- use the in-report Dialog form to ask a parameter value.
To do this:
- add the new dialog form ("Add New Dialog" button on the designer's toolbar);
- put a TextBoxObject on it (with name "TextBox1");
- edit your datasource object (in the "Data" window, select the datasource and click "Edit" button);
- modify your SQL query to use a parameter. For example (MS SQL): "select * from myTable where MyCol = @param1";
- go next page of the wizard, setup the parameter's Name, DataType properties (Name should be the same - @param1, DataType depends on MyCol data column type);
- setup the parameter's Expression property to use the TextBox1.Text value: "TextBox1.Text";
- setup the parameter's DefaultValue property; it is needed if you want to view datasource's data in the designer.
Note: you may need to convert the string value returned by TextBox1.Text to appropiate data format. You may use other dialog controls such as DateTimePicker or NumericUpDown.
Comments
To filter data in a report, doubleclick the "Data" band and switch to "Filter" tab. You can write any valid .Net expression here.
For example, in the "Simple List" report you can write the following expression to display employees which name starts with "A":
[Employees.FirstName].StartsWith("A")
if , you put an example in my program creates an order for sale, save, and I've put a button "preview", which is supposed to receive and filter the code of the order for sale, and that makes the second Preview
- for saying he created the "order of sale number 350 and I want to print it alone, with the format that I designed, of course that such an order covering the entire sheet.
- go "Data" window. If it is not visible, you can view it in the "Data|Show Data Window" menu;
- click "Actions" button in the "Data" window. Select "New Parameter" item;
- go "Properties" window and set up the DataType and Name properties for the parameter. The DataType property is very important, set it properly.
To set the parameter in your application:
report1.SetParameter("myparam", value_for_param);
To use the parameter in the data filter:
- set the data band filter to something like this:
[Employee.FirstName] == [myparam]
Regards
Daniel
In this example:
- use the in-report datasources (created in the "Data|Add New Data Source..." menu);
- use the in-report Dialog form to ask a parameter value.
To do this:
- add the new dialog form ("Add New Dialog" button on the designer's toolbar);
- put a TextBoxObject on it (with name "TextBox1");
- edit your datasource object (in the "Data" window, select the datasource and click "Edit" button);
- modify your SQL query to use a parameter. For example (MS SQL): "select * from myTable where MyCol = @param1";
- go next page of the wizard, setup the parameter's Name, DataType properties (Name should be the same - @param1, DataType depends on MyCol data column type);
- setup the parameter's Expression property to use the TextBox1.Text value: "TextBox1.Text";
- setup the parameter's DefaultValue property; it is needed if you want to view datasource's data in the designer.
Note: you may need to convert the string value returned by TextBox1.Text to appropiate data format. You may use other dialog controls such as DateTimePicker or NumericUpDown.