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

Returning e.Row.Item as a list?

3 Answers 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
madladuk
Top achievements
Rank 2
madladuk asked on 16 Jul 2010, 02:24 PM
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

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 19 Jul 2010, 02:26 PM
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
0
madladuk
Top achievements
Rank 2
answered on 13 Aug 2010, 03:41 PM
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?
0
madladuk
Top achievements
Rank 2
answered on 13 Aug 2010, 03:52 PM
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
Tags
GridView
Asked by
madladuk
Top achievements
Rank 2
Answers by
Milan
Telerik team
madladuk
Top achievements
Rank 2
Share this question
or