A datagrid id rendered to the client as an HTML table
<table><tr><td>... blah de blah
So thats what javascript is seeing, javascript will never know diddley squat about what the hell a datagrid is
Also you are using the ItemCreated event this happens before the ItemDataBound event so at that point
e.Item.Cells[4] is empty anyway and is a reference to the cell value not the cell itself.
I would use the 'this' property as the argument to your client function disp_prompt();
btn.Attributes.Add("onclick","disp_prompt(this)");
That will pass a reference to the button itself, or use the W3C DOM 'event' in your javascript which will be a reference to the element that raised the last event (eg the clicked button in the DOM), you can use knowledge of the DOM to find cell number four because cell number four and the clicked button share the same parent element (a table row)
so in your javascript function you can have something like:
function disp_prompt(button)
{
var number=prompt("Enter number","")
if (number!=null && number!="")
{
var row = button.parentElement;
var cell = row.cells[3];
var num = cell.innerHTML;
cell.innerHTML = (num+number);
}
}
You might need to check my javascript I havn't time to check the exact syntax but it shouldn;t be too disimilar to what I have posted.