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

Getting textbox and/or sum data values in codebehind

4 Answers 429 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 22 Jun 2017, 06:11 PM

I'm trying to make a textbox in the footer the difference of two textbox value.

One is a sum value of a data item, the other is a value generated via codebehind.

 

I've tried this:

Private Sub ReportFooterSection1_ItemDataBound(sender As Object, e As EventArgs) Handles ReportFooterSection1.ItemDataBound
        oConn.Open()
        Dim ocmd As New SqlCommand("SELECT * FROM tblDynamic", oConn)
        ocmd.CommandType = SqlDataSourceCommandType.Text
        Dim reader As SqlDataReader
        reader = ocmd.ExecuteReader
        If reader.HasRows Then
            reader.Read()
            _txtLoansPerFinancial.Value = reader("TotalLoansPerFinancials").ToString()
            _txtLoanDifference.Value = _txtLoansPerFinancial.Value - _txtTotalLoanBalance.Value
        End If
        oConn.Close()
    End Sub

 

Where the expression on _txtTotalLoanBalance is = Sum(Fields.PctRiskTierGT1) , however rather than get the value that the expression brings, it incorporates _txtTotalLoanBalance.value as the string "= Sum(Fields.PctRiskTierGT1)" and it gets an error.

 

How can I get the value of this text box, or the value of Sum(Fields.PctRiskTierGT1) in the codebehind?

4 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 27 Jun 2017, 11:30 AM
Hello Ryan,

I am not sure why you're receiving this error, in general aggregate functions could be set through the Edit Expression editor, please take a look at the following topic from our documentation for more details:  Aggregate Functions

If you're still experiencing the issue, I'd ask you to send us the report definition, so we to be able to research it locally. You should open a support ticket and attach it there.

Regards,
Yana
Progress Telerik
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
0
Ryan
Top achievements
Rank 1
answered on 30 Jun 2017, 01:41 PM

The aggregate function is working fine.

What I'm trying to do is add another value to this aggregate function, using the code I have posted. The problem is that the _txtTotalLoanBalance.Value is evaluating to the string "= Sum(Fields.PctRiskTierGT1)" instead of the actual sum when I am trying to access it in the codebehind.

0
Yana
Telerik team
answered on 05 Jul 2017, 01:38 PM
Hello Ryan,

Thank you for the clarification, I was able to observe the reported behavior.

Please take a look at the following documentation article:  Access Report Items Programatically which explains how you could access the needed TextBox and its value accordingly in code-behind.

In short,  you will need to use the ElementTreeHelper.GetChildByName method in order to locate the TextBox and cast it to Processing.ТеxtBox instead as this is the type we're using when processing the report.

Try it and let me know whether this helps.

Regards,
Yana
Progress Telerik
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
0
Ryan
Top achievements
Rank 1
answered on 06 Jul 2017, 07:52 PM
Thanks, that worked!
Tags
General Discussions
Asked by
Ryan
Top achievements
Rank 1
Answers by
Yana
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or