A Writing Prerequisites
In the first two, we talked about how to insert and use pictures in rdlc, in addition to pictures, we often need to use certain formats or use specific data under certain conditions, or do some processing on the data. And there may be some data to be provided by us from the ASP.net program, so this article is mainly about how to use parameters, expressions, and common constants in RDLC reports.
Because the recent project is relatively tight, there is no time to write too much complex things, and the brothers in the group more want to know the page at the end of the homepage and the combination of the design of the head, so I put a finished design template in the ReportTemplate folder, provided to you for reference.
Two The content of this article
1. How to provide parameters for RDLC reports through asp.net procedures
2. How to use the variables provided by RDLC and common constants
3. Use of commonly used expressions
4. Summary
5. Code download (download)
Three ASP.net program provides parameters for RDLC reports
In our reports, we often need to provide some parameters from the ASP.net program to the report at the specified location, in the first we have talked about how to pass a dataset, but we only need a value, It's not always possible to put this value into a dataset (because the dataset is actually made of XML, which requires more resources than the data itself), so this time we need to know how to pass a parameter to the RDLC report. Now let's talk about it.
I don't know if you remember the button event I wrote in the Default.aspx.cs in the first article, as follows.
1 protected void Buttonreportgenerate_click (object sender, EventArgs e)
2 {
3 list<reportdatasource> ReportDataSource = new list<reportdatasource> ();
4 Rportdataset ds = new Rportdataset ();
5 string TemplatePath = String. Empty;
6 string totalrecords = string. Empty;
7
8 SqlConnection conn = new SqlConnection (configurationmanager.connectionstrings ["Loggingconnectionstring"].C onnectionstring);
9 SqlCommand command = conn. CreateCommand ();
Ten command.commandtype = CommandType.Text;
One command.commandtext = "SELECT * from T_bc_logs";
SqlDataAdapter da = new SqlDataAdapter (command);
Da. Fill (ds. T_bc_logs);
Reportdatasource.add (New ReportDataSource ("Rportdataset_t_bc_logs", ds. T_bc_logs));
15
//templatefiles
TemplatePath = "REPORTTEMPLATE/LOGREPORT.RDLC";
list<reportparameter> parameterlist = new list<reportparameter> ();
////generate
Getreportmultipledatasourcefile (ReportDataSource, TemplatePath, Parameterlist, "pdf");
21}