# Having issues getting data out of datagrid

**URL:** <https://forum.kirupa.com/t/having-issues-getting-data-out-of-datagrid/278895>\
**Category:** flash\
**Created:** [January 7, 2009, 4:57am UTC](https://forum.kirupa.com/t/having-issues-getting-data-out-of-datagrid/278895 "2009-01-07T04:57:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sldhana](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sldhana](https://forum.kirupa.com/u/sldhana)\
**Post date:** [January 7, 2009, 4:57am UTC](https://forum.kirupa.com/t/having-issues-getting-data-out-of-datagrid/278895/1 "2009-01-07T04:57:27Z")

</div>

I have a data grid that lists out a list of video titles, etc. To get the title of the video when a row is clicked, I am using the ListEvent.ITEM\_CLICK event. This captures the event, but when I trace the selectedIndex using event.target.selectedIndex, I get weird values. Sometimes, the first click result is a -1 (if it’s a zero based index, it should start with 0, so -1 is perplexing). After the first click, it seems to the trace seems to return the previous click values. Code is below. Am I doing something majorly wrong here and not even realizing it?

function fetchCategoryData(event:Event):void{  
var selected = comp\_categories.selectedItem.label;  
var matches = videos.getMatch(selected);  
var matchData:Array = new Array();  
for(var i=0; i\<matches.length; i++){  
matchData.push({Play: matches\*.getPath(), Tags:  
matches\*.getTags().toString(), Title: matches\*.getTitle()});  
}  
comp\_videos.dataProvider = new DataProvider(matchData);  
comp\_videos.addEventListener(ListEvent.ITEM\_CLICK, getSelectedRow);  
}

function getSelectedRow(event:ListEvent):void{  
trace(event.target.selectedIndex);  
}
