This is a migrated thread and some comments may be shown as answers.

Rowcount from code behind

1 Answer 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 03 Feb 2017, 08:25 AM

Hi,

How do I accomplish a rowcount from code-behind? I have a report with two datasources, one is holding header info and the other one is holding detail rows.

I need, in code behind, count the number of rows in the detail datasource. Both datasources are SqlDataSource using SqlClient to connect to MS Sql server.

 

I have tried put a hidden TextBox in the report and set it's value to Count(Fields.[a field in details]). This gives me the error "An error has occurred while processing Report 'reportname': The expression contains object 'fieldname' that is not defined in the current context" Of course I've doublechecked and 'fieldname' is correct spelled... The field belongs to the details Datasource.

 

Ideas?

1 Answer, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 07 Feb 2017, 01:57 PM
Hello David,

You can create a user function that returns a string and use it as a TextBox.Value. the idea is to make the function get the RowNumber or the result of other expression as an argument, in order to have the current row information in code. The user function can return anything else suitable for the report.

We will appreciate it if you elaborate on the usage of the current row number in code.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Stef
Telerik team
Share this question
or