Sum or Count Character values
I have a requirement to sum and/or count the number of names in one of my report. They're string values.
Can string values be summed or counted? I was looking for a grand total of the number of names in a selection area.
Any assistance would be appreciated.
Walter
-
Walter,
I would use a script to loop through the datatable's row and concatenate the strings and count it, and display on the report.
This it is totally my imagination since I don't know your datasource.
Say you have one datatable on your dataset which is your datasource for the report.
Considering that dataTable named 'aTable" which has a column named 'name', and a rpx TextBox control called 'tbResult' on the Details section on Report.
(1) Open the rpx file using 'Report Designer',
(2) click 'Script' tab which is at the bottom of the designer, next to 'Designer' tab
(3) Choose 'Object' dropdownlist to 'Detail1', and choose 'BeforePrint' on Event dropdownlist
(4) Inside 'public void Detail_BeforePrint()' method, put your code something like:
// find the dataset of the report
DataSet ds = (DataSet)rpt.DataSource
// find a datatable
DataTable dt = ds.Tables["aTable"];
// set the stringBuilder placeholder
// loop through the DataRows, and find the dataColumn 'name' to get the value of each row, and Append it to the StringBuilder
// Assign the NUmber of final string count to the tbResult
0 -
Munwhan,
Again you're providing me with solid solutions. Thank you.
My data connection contains only 4x fields: FullGraveNumber, Site_Width, Site_Length, Deceased_Name, Status. What my client is asking for is the ability of the report to sum/count only the FullGraveNumber and Deceased_Names, as an indicator of which plots may or may not be yet sold.
Since I am not a C# programmer, can you please be so kind and provide some sample code for the bottom three items you've mentioned:
// find the dataset of the report
DataSet ds = (DataSet)rpt.DataSource
// find a datatable
DataTable dt = ds.Tables["aTable"];
// set the stringBuilder placeholder
???
// loop through the DataRows, and find the dataColumn 'name' to get the value of each row, and Append it to the StringBuilder
???
// Assign the NUmber of final string count to the tbResult
???
Thanks Munwham.........Walter
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare