I am using ASP.NET/C#.I am using Report Viewer control to display a basic report.Currently the data is shown properly however the column names are the same as when selected while configuring the Report Wizard.
Example:
cFirstName is displayed as cFirstName in the column header of the Report Viewer.
I would want to change it to First Name instead.
Here is the image of the issue.
Can anyone help me to achieve this?
Any suggestions are welcome.
Thanks.
You can set this in the rdl, rdlc file.
This is where it should normally be done.
It cannot be done through c#, unless you take that column name as a report parameter and set the column header using that parameter.
Related
I have report with some sub-report in it. Can I show/Hide the sub report based on the content in the table. For example, I have a column name "has_header" set to false and in that case I do not want the header-sub-report to display on the report.
I found the solution!! I went too complicated before trying the basic. In sub-report>> specify the filter: in my case I put Has_header=.T. and things is done. I am not sure if this is the exact solution but, it fixes my problem.
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.
I have inserted a dataset to my asp.net webpage, using Add New Item >> Dataset. I have bound it with my table in DB and also previewed data by right clicking Preview Data BUT the problem is previewing data through code.
I am quite familiar with using the datasets in vb.net but I wonder how to use them in asp.net.
I am simply tring to use through filling the TableAdapter, as
Me.TblSQsTableAdapter.Fill(Me.DsSQs.tblSQs, vrExamIDSetPaper)
but dsSQs (my dataset name) does not snow the table name when I press . as we do in vb.net winforms.
I want to get no. of rows that come under given parameter. e.g vrExamIDSetPaper
Plesae help.
Thanks
You need to inspect the Tables collection and then rows.
dsSQs.Tables(0)
dsSQs.Tables(0).Rows.Count
You can do it by using below code by that name vrExamIDSetPaper
dsSQs.Tables(vrExamIDSetPaper).Rows.Count// For how many rows
I have a report which contains 10 columns of stock values.
When a stock value is negative I would like the text in my report to be formatted differently, for example I may wish to format it in Bold & Red.
Is this something I need to do in the fetch method?
At the moment my fetch method is very basic, just using setRecord once to setup a temporary table.
Is it possible and if so how is it done?
Take a look on the tutorial_ColourLines report.
reportSection.foregroundColor(colour);
The report changes the color of a report section, but it can be done to individual report controls as well.
I have a report which has 3 subreports. In the case of no data I want to hide the report. It's giving me this error:
Error: Subreport could not be shown
How can I hide the subreports?
You are going to have to create some mechanism of knowing whether or not a subreport will successfully be shown on the main report because you aren't going to be able to "return" anything back to the main report from the subreport.
Could you create a small dataset on your main report that would query to check if data will exists for the subreport? and then you could use an expression on the subreport element (or container such as tablix or rectangle) to hide it based upon the results of the query on the main report.
Let me know if I need to clarify.
if we directly create a dataset in the main report itself then there is no question of using another report as a subreport we can directly use the fields from the data set created in the main report and assigning parameters to main dataset values. i think that will not server purpose.