rdlc report grouping data sort by numeric column - c#

I'm using rdlc report in C#. Inside rdlc report I had added one parent group and report shows data as I expected, Only problem is that I want to sort data by RowId Column This RowId is an int type(DataSet Column). Sort Order shows option A to Z and Z to A. Reference image is attached here.
Suppose I have Row Id 1, 2,3,4 ....40. This report will sort data like 1,11, 12,13...., 2, 21,.......
How to sort this data in order of 1,2,3,4.....40
I'm using visual studio 2015.
Is there any other way to sort data?

Finally I got solution to this problem, I use expression for converting existing value to int. Expression used is as below,
=CInt(Fields!RowId.Value)

Related

Crystal Reports for Visual Studio: display 2 unrelated tables

I ask for advice what would you suggest to display 2 unrelated tables in a single report (if needed with subreport), the first one with groupings and the second one "flat"?
Details:
I am developing a report with C# 4 and Crystal Reports for Visual studio.
Data comes from a Stored procedure in Sql Server 2005, that returns 2 tables.
I pass the data to the report with the .SetDataSource(Dataset) method and I checked that data in the dataset is correct.
I need to display the data from the first table in a quite complex form with different sections. This part works.
At the end of the report I need to print the data from the second table (no grouping, just a "flat" print). To do this I added a subreport.
The tables are not related. I added a Dummy field on them with the same value and used it to mimic a relation in the database expert; I configured the subreport link, based on the dummy field.
I have 2 problems.
The data in the main report is cross joined with the second table (I could expect that since they are related with a constant field)
The subreport is always empty (I checked several times that its table in datasource contains correct data).
I tried different configurations of link and tried to place the subreport in different sections (It should be in the report footer).
I set a border around the subreport: the border is printed but inside it is empty.
I also setup a formula to count the records of both tables and put the count in the report: the count is > 0 for both.
Your approach looks wrong.... At first if both are not releated I don't see any use in creating a dummy field and linking tables which will always provide cross join. Any way as per your descrition table 1 data is saperately displayed and table 2 data is saperately displayed
As per your description in main report you need data from table 1 and in footer you need data from table 2.
Try this approach:
Don't link tables
take table 1 in main report and show the required display.
Take sub report and in that take only table 2 and display in footer and make sure don't link main report and sub report nor link two tables.
Ideally speaking, without linked table not used in crystal report as reporting tools used to display the relevant data based on our criteria and display 2 different set of data without link does not mean as a report as well as tough to integrate in crystal report.
Tough to integrate means at any point you have to link the table either via union in sqlserver or at crystal report side, other wise it display as Cartesian.
As per my thoughts you can do it by some approach.
Approach 1 : You can get the data by union or unionAll with set of columns and filter the data where table's column does not have null value ie.
http://www.maximumimpactsolutions.co.uk/blog/comments.asp?bd=118
Table1col1 Table1col2 Table1col3 Table2Col1 Table2Col2 Table2Col3
value value value null null null --table1data
null null null value value value --table2data
Approach 2 : Second is sub-report, but still need the linked as you already done. But there is proper rule to be set (this is very very tedious job).
Approach 3 : Generate 2 report at c# side and merge into one PDF, then export it.
check this links.
Reporting on multiple tables independently in Crystal Reports 11
http://www.tek-tips.com/viewthread.cfm?qid=241195
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=4756
http://www.codeproject.com/Questions/348959/Crystal-reports-for-multiple-tables

Special field record number in crysal report not show when record does not exist

I am using crystal report asp.net visual studio 2012. I am showing table format data in crystal report and I am using special field record number as serial number but problem is when data not exist special field record number show 1.I want record number not display when data is not available.Which formula i will write to get rid of this problem.
I am getting following result when data is not available
SR NAME
1
I do not want record number
on your section expert under suppress condition you can write something like isnull(Name) or Name = "". Once that condition is true, it will suppress the entire row.

Crystal Report Crosstab String Data

I have a datatable that looks like this (all columns have string datatype)
firstCol secondCol thirdCol
1_str1 1_str2 5,1
2_str1 2_str2 5
3_str1 3_str2
.... .... ....
note that on the thirdCol, some fields are blank.
as for the crystal report, I have used the cross-tab feature
Columns: firstCol
Rows: secondCol
Summarized Fields: thirdCol
The columns and rows are okay. The only problem that I have is the summarized fields.
As far as I have searched, it is only used for numeric data (correct me if I'm wrong).
I even created a sample datatable and bound it on the crystal report. Instead of string, it displays the "numeric" (or you may call it integer, decimal, etc) datatype which is not what I want. Is there any way to display it as a string ?
this is the actual datatable
and this is the crystal report cross-tab output
nevermind the total column and row on the crystal report output. I just want to display "5,1" and "1" on the cross-tab, not the numbers.
Sure, you can display the summarized field as a string. When you created the crosstab, the default summary function is count() which is what you're seeing. Instead, go into your crosstab, select your summarized field, and hit the 'Change Summary' button. Instead of count you can use minimum or maximum (interchangeably, since I'm guessing that you will ever only have on entry for each row/column combination).
Once that change has been made, "5,1" will display for HCC and "5" will display for Legionella on Feb 14, and all other summarized fields will be null.

Crystal Reports Multiple Tables Issue

I have a C# 2010 application that uses Crystal Reports for VS 2010. My report's purpose is to show where a person should be each day of one or more weeks. The format is this:
Please note that it is displayed in pairs, rather than a table with a general header.
It uses a DataSet that contains two DataTables, one for the header dates and one for the location.
The problem is that if I have n items in each DataTable, the report displays n^2 pairs of header / location instead of just n. The pattern is similar to a Cartesian product of the two tables.
I think it might have something to do with the linking part in the report's Database Expert but I couldn't manage to fix it. It contains no links right now.
The DataSet I use looks like this:
Why do you need a table for the headers? What are you trying to accomplish?
Why not add a date (StartOfWeek) to the WeekTable that represents the starting date of the week? If you have that date, each column header would be a formula field that calculates the day based on the StartOfWeek field. So much easier and it eliminates the Cartesian product that you are experiencing.
** edit **
There would be 7 header formulae (one for each day):
//{#Sunday}
DateAdd("d", 0, {WeekTable.StartOfWeek})
...
//{#Saturday}
DateAdd("d", 7, {WeekTable.StartOfWeek})
Add each field to the Page Header section and format as desired (they are Date values).
You need to link the tables to only get n rows.
Ideally:
Add a unique ID column to the Headers table. Make it the one primary key, and an auto-incrementing identity.
Add a HeaderID column to the WeekTable table, and make it a foreign key to the Headers table on the ID column.
The Headers table should now only include one row for each week, so if you have four employees they will all have the same HeaderID for a given week.
You may need to explain a little further what your "header dates" are. But from what you're saying they are not linked to the main data, in which case i would probably use a subreport in the header.

How to Add SSRS Column Programmatically

I have a table Called EmployeeTypes which hold types of Employees, now i want to create a report using SSRS which will have something like this:
EmployeeType1 EmployeeType2 EmployeeType3
4 23 2
where the numbers are the count of employees.
problem is how can i generate the columns programmatically like that as the EmployeeTypes Table can have many Types and expand by time?
It sounds like you are looking for a cross tab report, using a data set like select count(*), employee_type from employee_table group by employee_type.
You can use the report wizard to create a 'Matrix' report type (as opposed to a 'Tabular' report type). The wizard will guide you through the steps to get what you need.
An SSRS report is defined by an XML file (the .RDL or .RDLC file). You could generate columns programmatically by directly modifying the XML. Not for the faint of heart, but people do it, and it can be done.
Here is a sample:
http://www.codeproject.com/Articles/11254/SQL-Reporting-Services-with-Dynamic-Column-Reports

Categories

Resources