Q1 - 2009 casting error

7 posts, 0 answers
  1. Ryan Emptage
    Ryan Emptage avatar
    28 posts
    Member since:
    Feb 2009

    Posted 20 Mar 2009 Link to this post

    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 ?

  2. Ryan Emptage
    Ryan Emptage avatar
    28 posts
    Member since:
    Feb 2009

    Posted 20 Mar 2009 Link to this post

    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()); 

  3. DevCraft banner
  4. Ryan Emptage
    Ryan Emptage avatar
    28 posts
    Member since:
    Feb 2009

    Posted 20 Mar 2009 Link to this post

    Its ok now.
    I worked out I needed to change the cast from DataObject.RawData to System.Data.DataRow
  5. Ryan Emptage
    Ryan Emptage avatar
    28 posts
    Member since:
    Feb 2009

    Posted 20 Mar 2009 Link to this post

    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; 



  6. Milen
    Admin
    Milen avatar
    163 posts

    Posted 20 Mar 2009 Link to this post

    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.
  7. Sypher
    Sypher avatar
    79 posts
    Member since:
    Aug 2006

    Posted 01 Jun 2009 Link to this post

    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.
  8. David Penrose
    David Penrose avatar
    33 posts
    Member since:
    Feb 2003

    Posted 04 Jun 2009 Link to this post

    What a find. I was looking at a long night until I came across your solution.

    Thanks!
Back to Top
DevCraft banner