How to add parameter and expression in rdlc - c#

I am getting a result of #error when I view it using ReportViewer reports
I was expecting to add the expression with the result of the two parameter
this is the syntax

Related

How to add parameter to Telerik Report Source?

I have added the Telerik Report Viewer to my windows form and set the report source as ConsignmentReport.Report1, ConsignmentReport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. ConsignmentReport is my telerik report designer class. My datasource for the designer is MySql and my sql query needs a parameter. I've set the connection string, data provider, query and parameter in the designer and everything works correctly in the designer preview. My parameter name is #jsno
Then, I tried to add the parameter for the ReportViewer like this
reportViewer1.ReportSource.Parameters[0].Value = "19020312";
and it did not work.
Also tried to add like this
reportViewer1.ReportSource.Parameters.add(new Telerik.Reporting.Parameter("#jsno","19020312"));
Also did not work.
My report viewer remains blank. When tried to remove the parameter from the query and just run the report viewer with simple select statement, the report is generated. So how could I add the parameter to the report source?
The report source parameters enable passing values to the report parameters. So, you need to first add a report parameter to the report definition, in order to be able to pass a value from the report source. On the other hand, you have the data source component which has its own parameters. To bind the data source parameter to the report parameter, do set the following expression as a value of the data source parameter: =Parameters.jsno
Then, at runtime to pass a concrete parameter value to the report, use the second snippet:
reportViewer1.ReportSource.Parameters.add(new Telerik.Reporting.Parameter("#jsno","19020312"));
More info at Using Parameters with the SqlDataSource component (You can use the designer to make the setup)

How can i order the columns of a grid from my c# code

Is there a way i can show the column of a telerik grid a defined order from the code?
list.Add(objFromCDF);
radGridCloseCard.DataSource = list;
This is the way i am filling the grid in my c# code. Using this method is giving me an error:
radGridCloseCard.Columns["Customer_No"].ToString().DisplayIndex = 0;
The error says "The best overloaded method match for 'Telerik.Web.UI.GridColumnCollection.this[int]' has some invalid arguments"
i assume you are using AutoGenerateColumns="True".
In order to specify the orders, you must specify each columns in the tag and set AutoGenerateColumns="False".
The order in which you specify the columns is the same used to display those columns.

SQL Server Report Builder 3 using SQL IN operator with parameter not working

I am attempting to filter a dataset in SSRS using the IN operator on a single column. When I add more than one value it fails.
For simplicity this is my SQL statement excluding other filters to focus on the new problem.
SELECT * FROM vActivityDetailed WHERE Category IN (#Category)
#Category is affected by an override expression under Dataset properties.
=Split(Parameters!Category.Value, ",")
Instead of using a multivalue parameter, I treat this as a single value and hope that by doing a split, the SSRS should execute like this.
C# - ASP.NET Code
string categoryString = "Expenses, Misc, Accounts-Receivable";
paramPayType.Name = "Category";
paramPayType.Values.Add((categoryString!= "" ? categoryString : null));
SSRS Final SQL Execution (Expected)
SELECT * FROM vActivityDetailed WHERE Category IN ('Expenses', 'Misc', 'Accounts-Receivable')
Since I've tested this directly on the SQL using SQL Server Management Studio, I know the above SQL should work since it returns records, but when applied in SSRS it fails with An error has occurred during report processing. (rsProcessingAborted)
The parameter value in SSRS is an array of strings when multiple values are selected. The Split function takes a single string as its argument. You can't use Split with an array. SSRS with SQL Server handles the splitting of the values for you so you should be able to just pass the parameter straight through.
If you need to actually split the values for some reason, I would recommend using a custom SQL function. There are lots of examples if you run a search for that.

SSRS Dynamic Returning Dataset Collection Field in Expression

I wrote a custom assembly to take a parameter value from the report and return a field from the dataset collection.
My assembly returns the correct fields!name.value, but it shows me the string representation of it. How can I get it to resolve as the actual fields!name.value to display the actual data in the dataset?
If I enter fields!name.value in manually it works fine showing me the value. If I resolve it with my custom code it display "fields!name.value" to me in the cell.

how to add parameters in report viewer?

HY! I have a form application in visual studio 2010 and I want to create a report with report viewer and to add some parameters. I tried to add parameters from code but it didn`t work. I have this error:
FilterExpression expression for the tablix ‘Tablix1’ refers to the field ‘datastart’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.
Report2.rdlc : error rsParameterReference: The FilterValue expression for the tablix ‘Tablix1’ refers to a non-existing report parameter ‘datastart’.
In my code a do this:
private void SetReportParameters()
{
ReportParameter[] parameters = new ReportParameter[2];
parameters[0] = new ReportParameter("datastart", dateTimePickerStartRaport.Text);
parameters[1] = new ReportParameter("dataStop", dateTimePickerStopRaport.Text);
this.reportViewer1.LocalReport.SetParameters(parameters);
}
and after calling this method a make a refresh on the report viewer
reportViewer1.RefreshReport();
I also look at other forums and I saw that I have to add the parameters to the report, but I didn`t manage out how must I do this. I also tried to add, in the properties windows of the report, some filters with value
=Parameters!datastart.Value
but this also didn`t work.
The error you get is because you try to specify your parameter like a field. In the expression-designer you have a special category called "Parameters". From there you can access your parameters.
The syntax is =Parameters![FieldName].Value. In your case for example =Parameters!datastart.Value.
Additionaly, note that the parameters must be declared in the "Report Data"-window under "Parameters". Its the same window as you use to declare your recordsets, however there is also a special category for parameters. There are also some options for the datatype and if specification of the parameter is mandatory.
So when you create report definition (rdl or rdlc file) you have to add parameters with exactly the same names. So for your case you have to add datastart and dataStop parameters. To do it just click Parameters in Report Data Window and click add new.
Try this:
ReportParameter PrmInvoiceNo = new ReportParameter("PrmInvoiceNo");
PrmInvoiceNo.Values.Add(this.InvNo.ToString());
this.reportViewer1.LocalReport.SetParameters(PrmInvoiceNo);

Categories