To demonstrate what I am doing I placed everything in one Javascript function.
function WebDataGrid1_RowSelectionChanged(webDataGrid, evntArgs) { document.getElementById('<%= HiddenField_SelectedRowIndex.ClientID %>').value = evntArgs.getSelectedRows().getItem(0).get_dataKey(); var grid = var grid = $find('<%= WebDataGrid1.ClientID %>').get_rows(); var row = grid.get_rowFromKey(document.getElementById('<%= HiddenField_SelectedRowIndex.ClientID %>').value); alert('Cell 0 in row should be = ' + row.get_cell(0).get_element().innerText);}
When I select a row in the WebDataGrid, The datakey value of the selected row is stored into a hidden value, when I check on that, the hidden value is indeed holding the datakey value.
Now, I have a button somewhere on the page that I will press, The javascript function there will find the Grid and get the row collection, the next lines you can follow, but what I do, even if I place the value hardcoded the grid.get_rowFromKey keeps resolving to null.
Any idea what I am missing?
I start further debugging and I found the following in your javascript code:
///<summary>///Returns a row by its data key. If the row is not instantiated yet it is being created and returned.///</summary>///<param name="dataKey" type="array">///Data key of the row to return. The data key is expected to be provided as an array, ///in the case of a single data key field it should be an array with a single item.///</param>
So the solution to my problem has been solved by creating an array with the value and pass that array.