Why does the SQL Server Reporting Service (SSRS) Report ‘appear’ to re-sort the data

rdlcreporting-servicessorting

The SSRS report in question is a client report file (.rdlc) and is created by 1) Querying the database and applying the returned populated System.Data.DataTable object to the report; 2) Calling the Export method on the report object in-order to create a final PDF file.

Problem: The query sorts the data in one way, and the report sorts it in another!

I know that an SSRS report does not support sorting, as that's up to
the query, hence my confusion!

I have used debug breaks to view the correctly sorted DataTable turn into an incorrectly sorted PDF. (Aaarrgghh)

The report simply lists products, their stock quantities, and their category e.g. Red Wine, White Wine, etc.

… and interestingly the PDF is sorted in what appears to be alphabetical order based on the first alphanumeric column of data, which is the third physical column called "Category".

I am using C#.NET 4 and Visual Studio 2010.

Best Answer

Your problem is your belief that "an SSRS report does not support sorting" - simply not true. You can sort data within the report. This is done through the properties of the Table, not with the Dataset properties as one might think.

Click anywhere on the table, right-click the top-left box and select Properties. This will display the properties for the entire table with the fourth tab being "Sorting". You should find that this section has been filled in for your report.

If this section is not filled in, then the output will be in the order of the results of the query for the dataset. However, it can be overridden using the table properties so that the one query can support different reports with different sorting and grouping.

Related Topic