I'm sure this is an easy fix...but it has defeated me so far.
I am trying to set the text in a textbox dynamically at runtime according to what the current datarow items contain. I have been trying to create a simple test to get the syntax worked out but have been having no luck. I have been unable to locate the answer in the forums either.
My report consists of a main report which contains a sub-report. The sub-report is where the tbtest textbox is located. I am using SQL Datasources for both the main and sub reports.
The following code is located in the sub-report codebehind (VB):
When I try to run the report I get the following error:
An error has occured while processing DetailSection 'detail':
Unable to cast object of type 'DataObject' to type 'System.Data.DataRow'.
Any help would be appreciated. Thanks.
I am trying to set the text in a textbox dynamically at runtime according to what the current datarow items contain. I have been trying to create a simple test to get the syntax worked out but have been having no luck. I have been unable to locate the answer in the forums either.
My report consists of a main report which contains a sub-report. The sub-report is where the tbtest textbox is located. I am using SQL Datasources for both the main and sub reports.
The following code is located in the sub-report codebehind (VB):
Private Sub detail_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles detail.ItemDataBound |
'Get the detail section object from sender |
Dim section As Telerik.Reporting.Processing.DetailSection = DirectCast(sender, Telerik.Reporting.Processing.DetailSection) |
'From the section object get the current DataRow |
Dim row As System.Data.DataRow = DirectCast(section.DataObject.RawData, System.Data.DataRow) |
If (row("Hospital") <> Nothing) AndAlso (row("Surgeon") <> Nothing) Then |
Dim testTextbox As Telerik.Reporting.Processing.TextBox = DirectCast(section.ChildElements.Find("tbtest", True)(0), Telerik.Reporting.Processing.TextBox) |
testTextbox.Value = "Hospital and Surgeon exist" |
End If |
End Sub |
When I try to run the report I get the following error:
An error has occured while processing DetailSection 'detail':
Unable to cast object of type 'DataObject' to type 'System.Data.DataRow'.
Any help would be appreciated. Thanks.