Click here to Skip to main content
Click here to Skip to main content
Go to top

Tips on SSRS

, 11 Oct 2013
Rate this:
Please Sign up or sign in to vote.
Below are some tips in SSRS:1.      ToDisplay Top N rows in report using Tablix controlCreate a parameter with IntegerDataType and select Default

Editorial Note

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

Below are some tips in SSRS:

1.      ToDisplay Top N rows in report using Tablix control
Create a parameter with IntegerDataType and select Default values from Properties, under specific values addexpression number of rows you want to display (i.e cint(10)). Now right clickon Tablix control and select properties, select Filters and add new filter
Expression=FieldName
Operator=Top N
Value= =Parameters!TopN.Value as expression.
Now in Report it will display Top N rows.

2.      To GetTotal Pages and Page Number for each Page in Report Footer
Add Textbox and assign the below expression to display total pages and pagenumber in Footer of report
="Page "+ Globals!PageNumber.ToString() +" of"+Globals!TotalPages.ToString()

3.       Viewing SSRS reports using ReportViewer
Add below sample code to view report whichdeployed in server:

ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://computername:8080");
ReportViewer1.ServerReport.ReportPath = @"/Examples/Sample";
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportServerCredentials _ReportCredentials = new ReportServerCredentials("windowsuserid","password");
ReportViewer1.ServerReport.ReportServerCredentials = _ReportCredentials;
ReportViewer1.ServerReport.Refresh();
ReportViewer1.AsyncRendering = false;
ReportViewer1.SizeToReportContent = true;

4.      Adding Fontstyles in Run Time to Tablix controls or Textboxes in SSRS Reports
Select Report from menu and select code from the menu add following code toadd font styles to controls in run time. I have report and want to add fontstyles of Report Heading in run time
Public Function GetColor(ByVal Section as String) as String
IF Section ="Report Heading" Then
                                Return "SteelBlue"
        End IF
End Function
Public Function GetSize(ByVal Section as string) as String
                IF Section = "ReportHeading" Then
                                Return "20pt"
                End IF
End Function
Public Function GetFont(ByVal Section as string) as String            
                Return "Arial"    
End Function
In Report Header I have added Textbox to display the Report heading and addstyles in Run time.
Now right click on Textbox and select properties, under Font add following expressionto add styles in run time. 
In Font ==Code.GetFont(“ReportHeading”) as expression
Size==Code.GetSize(“ReportHeading”) as expression
Color== Code.GetColor(“ReportHeading”) as expression

5.      To  Hide/Show  Textboxes,Tablix controls in Runtime
If there is no data to display in Tablix, then I don’t want to displayTablix control in report.
Right click on Tablix control and select Visibility and add below expressionunder show or hide based on an expression.
=iif(RowNumber(Nothing)> 0,False,True).
This will hide tablix if data is not present, otherwise itwill display the table with data.

6.      To addalternative row colors in Tablix control
Right click on details group of Tablix control, under backgroundColor addbelow expression
=iif(RowNumber("DataSet") mod2 = 0,"Steelblue",”White”)

7.      FormattingDateTime in Report parameters
=Format(Parameter!Parameter1.value,"MM/dd/yyyy")
=Format(Parameter!Parameter1.value,"dd/MM/yyyy")
=Format(Parameter!Parameter1.value,"yyyy-MM-dd")
=Today()              //CurrentDate

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ASP.NET Community

United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.
 
The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

247 members


Comments and Discussions

 
Questionshow report header above the report parameters in report view using SSRS? Is it possible ? pls suggest. PinmemberMukesh Bhagat19-Aug-14 11:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid