no selected row

I use the following code in order to detect a value of a selected row in a datagrid:

gridElencoContrattiPersonalizzati.cells(gridElencoContrattiPersonalizzati.getSelectedRowId(),0).getValue();

How can I detect whether no row is selected?

Try:

if (gridElencoContrattiPersonalizzati.getSelectedRowId()!=null)
{
gridElencoContrattiPersonalizzati.cells(gridElencoContrattiPersonalizzati.getSelectedRowId(),0).getValue();
}

it works very well…thanks