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

Q1 - 2009 casting error

6 Answers 165 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ryan Emptage
Top achievements
Rank 1
Ryan Emptage asked on 20 Mar 2009, 09:58 AM
Unable to cast object of type 'Telerik.Reporting.Processing.Data.DataGroup' to type 'System.Data.DataRowView'

on this code:

_memberId = int.Parse(((System.Data.DataRowView)(itemBase.DataObject))["MemberID"].ToString()); 




So what do I cast the DataObject to now ?

6 Answers, 1 is accepted

Sort by
0
Ryan Emptage
Top achievements
Rank 1
answered on 20 Mar 2009, 10:00 AM
sorry, here's the code in full, might make more sense now.

//Get the member id 
            Processing.ReportItemBase itemBase = (Processing.ReportItemBase)sender; 
            _memberId = int.Parse(((System.Data.DataRowView)(itemBase.DataObject))["MemberID"].ToString()); 

0
Ryan Emptage
Top achievements
Rank 1
answered on 20 Mar 2009, 10:12 AM
Its ok now.
I worked out I needed to change the cast from DataObject.RawData to System.Data.DataRow
0
Ryan Emptage
Top achievements
Rank 1
answered on 20 Mar 2009, 10:17 AM
oops, spoke to soon....I now get ArgumentOutOfRangeException

"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"

Processing.ReportItemBase itemBase = (Processing.ReportItemBase)sender; 
DataRow drv = (DataRow)itemBase.DataObject.RawData; 



0
Milen | Product Manager @DX
Telerik team
answered on 20 Mar 2009, 03:07 PM
Hello Ryan Emptage,

We apologize for the lack of information on using the DataObject property. The help content will be updated for the next release.

So you have figured out correctly that the RawData property of IDataObject returns the raw data that the sender is bound to. It may be System.Data.DataRow (if you are using datasets) or for example a business object if you are binding to some list of business objects.

The other helpful member is the string indexer. You can directly get the value of some column/property of your data object. Try using itemBase.DataObject["MemberID"] to get the value you need.

If you receive some unexpected errors, please send us a sample report with its data so that we can reproduce the error and help you further.

Kind regards,
Milen
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Sypher
Top achievements
Rank 1
answered on 01 Jun 2009, 07:54 PM
Ryan,

Seems this just changed in 2009 Q1.  It was working the way you had it in the 2008 releases.  I had the same object casting that you had, probably from a sample we saw somewhere.  I got it to work this way:

_memberId = int.Parse(itemBase.DataObject["MemberID"].ToString());

So I didn't have to cast the Telerik.Reporting.Processing.Data.DataGroup DataObject any longer. 

We both must have missed the breaking change warning in the update release notes.
0
David Penrose
Top achievements
Rank 1
answered on 04 Jun 2009, 05:26 AM
What a find. I was looking at a long night until I came across your solution.

Thanks!
Tags
General Discussions
Asked by
Ryan Emptage
Top achievements
Rank 1
Answers by
Ryan Emptage
Top achievements
Rank 1
Milen | Product Manager @DX
Telerik team
Sypher
Top achievements
Rank 1
David Penrose
Top achievements
Rank 1
Share this question
or