# HELP NEEDED: Get value of a selectedItem in a DataGrid?

**URL:** <https://forum.kirupa.com/t/help-needed-get-value-of-a-selecteditem-in-a-datagrid/267532>\
**Category:** flash\
**Created:** [August 2, 2008, 9:40am UTC](https://forum.kirupa.com/t/help-needed-get-value-of-a-selecteditem-in-a-datagrid/267532 "2008-08-02T09:40:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenwio](https://avatars.discourse-cdn.com/v4/letter/k/eada6e/32.png) [@Kenwio](https://forum.kirupa.com/u/Kenwio)\
**Post date:** [August 2, 2008, 9:40am UTC](https://forum.kirupa.com/t/help-needed-get-value-of-a-selecteditem-in-a-datagrid/267532/1 "2008-08-02T09:40:38Z")

</div>

Hi everyone!

What do I have to do to get the value of a selectedItem in a DataGrid? I wan’t this to happen dynamically.

**1 This works:**

```auto
 trace(event.currentTarget.selectedItem.station_name);

```

Here I give the selectedItem an existing object, station\_name. And it works - it gives me the value of that column/row. But this is not dynamic…

\*\*2 But I have an array consisting of the headerText values of the DataGrid I’m running the selectedItem on. \*\*

```auto
var rowDataField:String = array[event.columnIndex].headerText

```

So:  
How do i glue \*event.currentTarget.selectedItem \*and the value of _rowDataField_ together to form a valid statement?  
For example,

```auto

trace(event.currentTarget.selectedItem.[rowDataField];

```

The rowDataField could be:

```auto
trace(event.currentTarget.selectedItem.station_name
trace(event.currentTarget.selectedItem.station_type
trace(event.currentTarget.selectedItem.station_address

```

This would then give the value that I’d want

Any ideas anyone? This is getting frustrating…  
Kenwio
