Returning e.Row.Item as a list?

4 posts, 0 answers
  1. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 16 Jul 2010 Link to this post

    Hi.

    When I click on a datarow I have a custom event that passes the e.Row.Item to another handler (the datagrid is bound using your datatable examples). However as the table binding is dynamic then I dont know what fields would be populated therefore how can I get the values in a more readable source?

    Example

    If I had field1 in the datarow then e.Row.Item.field1 would be valid however I need to dynamically call the field so would need something like e.Row.Item[searchfield] (search filed would be a string value of the field I wanted to retreive the value for).

    Thanks
    P
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 19 Jul 2010 Link to this post

    Hi madladuk,

    You can cast the specified item to DynamicObject and use its GetValue method:

    var rowData = (DynamicObject) e.NewData;
    rowData.GetValue<int>("ID");


    All the best,
    Milan
    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
  3. DevCraft banner
  4. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 13 Aug 2010 Link to this post

    Hi.

    GetValue does not appear as a method and now I am trying to capture a rows values when doubleclicking a row using RowActivated. If I cast it as a DynamicObject it fails and returns null. Any other ideas?
  5. madladuk
    madladuk avatar
    126 posts
    Member since:
    Dec 2009

    Posted 13 Aug 2010 Link to this post

    Not sure if this is the best method, however sorted it using the following;

    radGridView1.SelectedItem.GetType().GetProperty("picktext").GetValue(radGridView1.SelectedItem, null)

    Thanks
    P
Back to Top