<p>I have GridView which I can select a row. I then have a button above the grid called Edit which the user can click to popup a window and edit the selected row. So the button will have Javascript code behind it along the lines of</p>

<pre><code>function editRecord()
{
  var gridView = document.getElementById("&lt;%= GridView.ClientID %&gt;");
  var id = // somehow get the id here ???
  window.open("edit.aspx?id=" + id);
}
</code></pre>

<p>The question is how do I retrieve the selected records ID in javascript?</p>

1) change your javascript function to use a parameter
```
```
function editRecord(clientId)
{ ....
```
```
2) output the call in your editRecord button... if you want to avoid dealing with the .net generated ids, just use a simple
```
```
<input type="button" onclick="editRecord(your-rows-client-id-goes-here)" />
```
```