how to clear subreport value in telerik report - asp.net

I am using Telerik Report in ASP.NET. I have one master report and inside that 2 sub report.
The formate of my report is for each unit I want to print sub report.
All are working fine but problem is sub report displaying only last record only those are assigned last in loop.
I have 8 record in the database. while I debugging my code it assigning proper value to sub report. but on output it showing last two record for all unit.it means sub report displaying same data for all unit.
I am assigning sub report data from function, I am not using any event for assign report source to sub report.
can any one please give me solution about this...?
Thanks

Related

Single prompt parameter(Date Range) for shared parameter in sub-reports' queries in Access 2010

I am using Access 2010 and have used a sub-report in the main report. The main report comes out fine, but the date range parameter (Between [enter start date] And [enter end date]) has been asked twice, one time for the main report and another time for the sub report.
I would like to parse the parameter only once. I followed below method mentioned in one of the article, but the numbers are wrong since the sub report takes only very first date from the result and parse it to the sub report(instead of parsing both "From" and "To" values.
Please help to enter the date range just one time.
I have followed:
You need to put your parameter in the query behind your main report and make it come out as a field:
SELECT YearParam:[Enter Year], <<Other Fields Here>> FROM <<Table NAME>>
Then on the main report, place a textbox in the Report Header with a control source of the field name (YearParam) and name the textbox (txtYearParam, for example).
Now, on each of the queries behind your sub-reports (or on the report filter) make it look at the main report textbox using the following syntax:
Reports!ReportName.txtYearParam
Article link.

SSRS Sub-Report only using default parameter to create dataset, even though parameter is successfully being passed from the main report

I have been working with SSRS for the last year and a half or so. Everything I know from it has been learned by trial and error and google. So hopefully I get my terminology correct, but forgive me if I say something incorrectly.
I am using Visual Studios 2015, connecting to SQL 2012 server. I'm creating an asp.net/VB web application to display SSRS reports on a local site. All of my reports up to this point have been a single report with no sub-report. If "sup-report data" was desired, I created a drill-through, using an Action, to navigate to a completely separate page. This has been working really well for all my reports, but now I would like to get a little fancier.
I have been trying to create a SSRS report that contains a sub-report. The main report contains summary information about batches of a particular product that has been run (blue and white portion of the table in the picture).
If a user wants to view more specific details about the batch, they can click on the expand/collapse button of the "Process Order" column, and a sub-report below the summary line will appear with more specific information about the batch (sub report is the light grey/dark grey table).
I configured the properties on the main report to pass the ProcessOrder value as a parameter on the sub-report and create a parameter on the sub report to accept this parameter.
You can tell that this parameter is being passed successfully because I have the respective parameter being passed and displayed just above the table (and it matches the number on the main table). As you can see from the picture, I also have the Process Order number displayed on the sub-report table itself, and this number is different than what is being passed to the report. It is showing a "1", which is the default value that I gave to the SQLDataSource control on my aspx page to build the dataset. I've tried not setting a "Default value" but then I get the following error:
“Data retrieval failed for the subreport, 'test_Sub_Report2', located at: [location on hard drive] Please check the log files for more information.”
Has anyone encountered this problem before, or can anyone give me an idea of a direction to go from here? I feel like I’m very close since I’m getting the parameter successfully passed to the sub-report, but the dataset is just not using that parameter to go get the data from SQL, and I’m not sure how to tell it to do so.
I can add more details and post more of the actual code, just let me know what you need and I will do my best to get it to you. I would have included more screenshots, but I don't have enough rep points to do so yet.
You need to go into the DataSet that populates the sub-report, and go to the Parameters tab, and map the ProcessOrder parameter of the dataset to the Variable that you pass the ProcessOrder parameter to from the main report.
I ended up figuring out the answer. I used the answer from #Lazy Coder on this question: SubReport is not working after adding parameter I was adding the parameters to the sub-report incorrectly. I did have them passed to the sub-report through the table on my main report, which was getting the parameters to the sub-report, but the sub-report was not using these values to create the data set. On my test_page.aspx.vb file I had to change my SubReportProcessing Event Handler. I needed to explicitly set the parameters values there. Since the time that I originally posted this question, I added another parameter to my stored procedure as well, subTotalTime, to correctly filter my results.
Public Sub SetSubDataSource(sender As Object, e As SubreportProcessingEventArgs)
Dim report = DirectCast(sender, LocalReport).DataSources(0)
Dim subProcessOrder = e.Parameters("subProcessOrder").Values(0)
Dim subTotalTime = e.Parameters("subTotalTime").Values(0)
SqlDataSource_PPMS_test_Sub_Page.SelectParameters(1).DefaultValue = subProcessOrder
SqlDataSource_PPMS_test_Sub_Page.SelectParameters(2).DefaultValue = subTotalTime
e.DataSources.Add(New ReportDataSource("DataSet2", SqlDataSource_PPMS_test_Sub_Page))
End Sub
SqlDataSource_PPMS_test_Sub_Page is the id of my SqlDataSource object on my aspx page.

Where clause in RDLC reporting

=iif(Fields!SubjectCode.Value=Parameters!SubjectCode.Value,Fields!SpAbsentCount.Value,0)
I have a Main Report and a sub report
SubjectCode parameter is passed to the subreport from the main report
for each subject code sub report is generated. based on the subject code I need to select a single value(SpAbsentCount) to display on the sub report
something like select... from... where SubectCode=#SubjectCode
I tried the above expression but it doesn't work
Hard to say exactly without knowing the data and setup of your report, but one guess I have is that you have a whole set of values, and your IIF expression winds up looking at only the first row of values. Try creating a tablix or list that filters on the SubjectCode, then using your code.

In JReport, how can I use the value of main report's field in UDS into formula of sub report?

In Jreport, I have a main report and a sub report. The data module is 1 : n for main report and sub report. Now I need to use main report's field in UDS as the column header in sub report, and suppress the header if the value in the field is null. To implement this, I create a parameter in catalog to receive the field value from main report. With this, the columns header in sub report are shown correctly, but if I create a formula to toggle suppress/show and use it in the column header, the data in sub report disappeared.
Has anyone run into this issue before?
I have sort out this issue by add line "pagenumber;" in the top of the formula.

Passing Parameters to Sub Reports in RDLC Under VS 2010

Currently I'm working on a reporting website in VS 2010 using ASP.Net 4.0 and the 2010 RDLC designer. The report I'm building is similar to a Master-detail report, but I'm trying to do it with nested tables.
My issue is that I'm trying to pass a field value from my main report to a sub report. The table setup looks something like this:
2 Tables
First Table: [RecordID, Name, Date,]
Second Table: [RecordID, Description, DueDate]
What I want to do is a table like this:
-------------------
| Name | Date |
------------------------------------
| Description1 | DueDate |
------------------------------------
| Description2 | DueDate |
------------------------------------
| Name2 | Date2 |
-----------------
With the entries for Description and DueDate bieng part of the sub report.
When I try to pass the RecordID in to the subreport as a parameter, which I have to manually define in the XML of the subreport because I can't find anywhere in the designer UI that will allow me to add report parameters to RDLC files, I get an error from the main report that says:
An error occurred during local report processing.
Value cannot be null. Parameter name: value
So it appears to be erroring out before it ever reaches the point where it does the subreport loading.
I am getting data sent to the main report just fine, and if I remove the parameter from the subreport the data comes through. But if I add the parameter the report throws the error.
Does anyone have any ideas on what might be causing this?
I actually ended up figuring this out.
If you're using Visual Studio 2010 you need to go into the report definition file and make sure the Report Data window is open.
If you can't find it go to View and click on Report Data.
Once you have the window open right click on the Parameters folder and add the parameter there.
In the parameter declaration box make sure you select Allow Null Value and Allow Blank Value if it's a Text type. This should stop that error from happening.
For some reason, even though I always had a value, with local reporting it initializes the report parameter with null causing it to throw that error if you do not allow nulls/blanks.
Nobody seems to understand that the sub-report data needs to be shown /filtered based on the main report column values. Sorry for complaining but after spending quite a time, I figured this out.
We need to define report parameters as mentioned above in the subreport, we need to pass the parameter values to the datasource used by sub-report to display the subreport data. Given below is the snippet.. I have used ObjectDataSource to populate the subreport.
Public Sub SubreportProcessingEventHandler(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
'e.Parameters.Item(0) is the report parameter defined in Sub-report
ObjectDataSource2.SelectParameters("Param1") = New Parameter("Param1", DbType.Int32, e.Parameters.Item(0).Values(0))
ObjectDataSource2.SelectParameters("Param2") = New Parameter("Param2", DbType.String, e.Parameters.Item(1).Values(0))
e.DataSources.Add(New ReportDataSource("SubReportDataSourceName", ObjectDataSource2))
End Sub
I just ran into same thing converting a report from VS2005. Anyhow, another thing I found was that the parameter had to be set in TWO places...
First, in the sub-report version, you have to declare the parameter(s) you are EXPECTING to receive coming in and its respective type.
In addition, from the MAIN report, if you right-click to the sub report, properties, there is a section for the "Parameters" that you want to pass TO the sub report. This would be from whatever record basis in the master report that will drive the sub report.
Just wanted to pass this on as clarification to others who may encounter or just be learning about handling sub reports in VS2010.

Resources