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

Change to version 2010 Q1 and now unabled to cast datarow in GroupHeader_ItemDataBound event.

2 Answers 74 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Benoit Massy
Top achievements
Rank 1
Benoit Massy asked on 16 Mar 2010, 05:45 PM
Hi,

I've made some reports with the tryal version 2009 Q3 and, just installed the developper version 2010 Q1. While the installation, it asks me to uninstall previous versions. I did. Install the version and make an upgrade with the Telerik Report Upgrad wizard. So, in several reports, I trap the GroupHeader_ItemDataBound event, cast the sender to a GroupSection variable and cast the in a datarow like the next exemple :

Private Sub moduleIDGroupHeader_ItemDataBound(ByVal sender As ObjectByVal e As System.EventArgs) Handles moduleIDGroupHeader.ItemDataBound  
        Dim Group As Telerik.Reporting.Processing.GroupSection = DirectCast(sender, Telerik.Reporting.Processing.GroupSection)  
        Dim txtTitle As Telerik.Reporting.Processing.TextBox = DirectCast(Group.ChildElements.Find("txtDMTitle"True)(0), Telerik.Reporting.Processing.TextBox)  
        Dim txtDescription As Telerik.Reporting.Processing.TextBox = DirectCast(Group.ChildElements.Find("txtDMDescription"True)(0), Telerik.Reporting.Processing.TextBox)  
 
        Try 
 
            ' Dim row As System.Data.DataRow = DirectCast(Group.DataObject.RawData, System.Data.DataRow)  
            Dim row As System.Data.DataRow = DirectCast(Group.DataObject.RawData, System.Data.DataRow)  
            txtDescription.Visible = row("DMPDescription")  
 
            txtTitle.Visible = row("DMPTitle")  
            txtTitle.Style.Color = System.Drawing.Color.FromArgb(28, 51, 97)  
 
        Catch ex As Exception  
            Stop 
        End Try 

When the compiler execute the line Dim row As System.Data.DataRow = DirectCast(Group.DataObject.RawData, System.Data.DataRow),
It append an error with the message "Impossible to cast an objet of type '<EnumRawData>d__0' in 'System.Data.DataRow."

I tried to cast to an array of rows, Build, Rebuild, Clean, etc..

Thanks a lot,

Ben

2 Answers, 1 is accepted

Sort by
0
Benoit Massy
Top achievements
Rank 1
answered on 16 Mar 2010, 07:56 PM

The solution is to do like a new way like explain in Telerik documentation. The code look now like this :

Private Sub moduleIDGroupHeader_ItemDataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles moduleIDGroupHeader.ItemDataBound  
        Dim Group As Telerik.Reporting.Processing.GroupSection = DirectCast(sender, Telerik.Reporting.Processing.GroupSection)  
        Dim txtTitle As Telerik.Reporting.Processing.TextBox = DirectCast(Group.ChildElements.Find("txtDMTitle", True)(0), Telerik.Reporting.Processing.TextBox)  
        Dim txtDescription As Telerik.Reporting.Processing.TextBox = DirectCast(Group.ChildElements.Find("txtDMDescription", True)(0), Telerik.Reporting.Processing.TextBox)  
 
        Try  
            Dim oDMPDescription As Object = Group.DataObject("DMPDescription")  
            Dim oDMPTitle As Object = Group.DataObject("DMPTitle")  
            txtDescription.Visible = DirectCast(oDMPDescription, Boolean)  
            txtTitle.Visible = DirectCast(oDMPTitle, Boolean)  
            txtTitle.Style.Color = System.Drawing.Color.FromArgb(28, 51, 97)  
        Catch ex As Exception  
            MsgBox("moduleIDGroupHeader_ItemDataBound: " & ex.Message)  
 
        End Try  
          
 
    End Sub 

Few hours to update my reports' code :-(
0
Steve
Telerik team
answered on 18 Mar 2010, 02:27 PM
Hello Benoit Massy,

First let me apologize for the troubles caused. You would be happy to know that we have released an internal build yesterday that reverts the IDataObject.RawData behavior to the state before 2010 Q1.

As you already know we have introduced a new to Telerik Reporting concept of data source components that allows the reports and the reporting engine to connect to different data sources in a better way than before. You see that this is a big step but it opens a lot new opportunities for the reports and our clients respectively (data source parameters, significant performance improvements and optimizations).

As of 2010 Q1 version of Telerik Reporting the data source components are the recommended way to connect a report to data; for backwards compatibility you can still connect a DataSet or DataTable but they are converted internally for you to the ObjectDataSource component (ref.: note). This is where the things have slightly changed (again for the reasons stated above) and you would start receiving DataRowView objects instead of DataRow.

Thank you for the understanding and sorry for the inconvenience once again.

Regards,
Steve
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
General Discussions
Asked by
Benoit Massy
Top achievements
Rank 1
Answers by
Benoit Massy
Top achievements
Rank 1
Steve
Telerik team
Share this question
or