Values on Winform and RDLC Report Designer

LabProARW

Well-known member
Joined
Nov 4, 2019
Messages
52
Programming Experience
1-3
I have a form with a ReportViewer control on it. When the form opens the ReportViewer loads and I see the NumberOfProducts from an expression in the RDLC file. In the expression in the RDLC file II use a text box with this expression: "=CountDistinct(Fields!ProductName.Value)" to get the total number of different products found. I'm drawing a blank on how to take that number and use it elsewhere (like a pie chart on the form that the ReportViewer is on). I should only have to derive that value once - so I resist programmatically finding the same value through code elsewhere in the parent form. Have been trying to reference the RDLC file text box value from the parent form but cannot get the syntax right... or even if that is what I should be doing in the first place.

Thank you for your response.
 
I'm drawing a blank on how to take that number and use it elsewhere (like a pie chart on the form that the ReportViewer is on). I should only have to derive that value once - so I resist programmatically finding the same value through code elsewhere in the parent form.
If you only want to get the value once then you're doing it the wrong way around. You don't get a ReportViewer to do work and then get data out of it. You can do the appropriate work in the form and pass the data into the ReportViewer but not the other way around. You can retrieve all the data and do the appropriate processing in the form or you can use a more complex query to do the processing in SQL and get the data in its final form. Either way, you can pass data into a ReportViewer but you don't take it out.
 
If you only want to get the value once then you're doing it the wrong way around. You don't get a ReportViewer to do work and then get data out of it. You can do the appropriate work in the form and pass the data into the ReportViewer but not the other way around. You can retrieve all the data and do the appropriate processing in the form or you can use a more complex query to do the processing in SQL and get the data in its final form. Either way, you can pass data into a ReportViewer but you don't take it out.
Let me explain how one gets to the point of asking my question. Using Visual Studio, and following various tutorials I end up getting my report almost looking the way I want. The ReportViewer.rdlc tab on Visual Studio makes it reasonably simple offering the ability to place an 'expression' into a control and to do some grouping. I thought I was OK until needing to add a pie chart to the same report. The pie chart control caused me to go back to code in the form. My total number of products and percentages had been done on the ReportViewer.rdlc, so that is why the question to get that value. I think my difficulty is in using Visual Studio interface to achieve the desired report display. I will follow your direction and use more code in the form and not rely on the function VS has built into the ReportViewer.

Thank you.
 
Are you aware that reports can contain charts that can then be displayed by ReportViewer? You may even be able to do it in the same report. Even if it's a separate report, you can probably use the same data source as the other and put the calculations there, or else just duplicate the calculations in the two reports.

I've only ever used charts in server reports but I would assume that client reports would support them too.
 
Are you aware that reports can contain charts that can then be displayed by ReportViewer? You may even be able to do it in the same report. Even if it's a separate report, you can probably use the same data source as the other and put the calculations there, or else just duplicate the calculations in the two reports.

I've only ever used charts in server reports but I would assume that client reports would support them too.
I am experimenting with a pie chart in the ReportViewer now. Is there a cache somewhere that holds changes? I have made some changes to the pie chart that are not being reflected on the ReportViewer. It's almost like my RDLC file is not being overwritten with new changes.
 
Considering how in your other thread you already found out how buggy finicky that control can be, I wouldn't be surprised if it has some other buggy odd behaviors.
 
Back
Top Bottom