How to import the data from the grid to a text field

Dear All,
Consider i have a grid with column name as
1)Name
2)Unique Id

I have a button if i click the button the grid will be loaded with the above columns.Now if i select a row i must get the selected name in a text box and unique id in another text box.Pl do reply .

Thanks
Krishnan

var id = mygrid.getSelectedRowId();
var name = grid.cells(id, 0);
var uniqid = grid.cells(id, 1);

above code uses columns indexes, if you want to use column ids it will be as

var name = grid.cells(id, grid.getColIndexById(“Name”));