Hi,
I am not new to ASP and c# but fairly new to Javascript. I have a Datagrid with a button column and a text column. The button is linked to a Javascript which when pressed prompts the user to enter a number. Upon entering a number and clicking 'OK', I want the number to be added to whatever number is present in the Text column.
I have been able to get the number correctly. The part that I have not been able to figure out is 'How to access the current row/column from the Javascript so I can take the number and add it to the TextBox cell'. I tried passing the current cell object to the Javascript but it gives me an error.
Here's my C# code
private void dgTest_ItemCreated(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemIndex >= 0)
{
Button btn = (Button)e.Item.Cells[3].Controls[1];
[B]//Does not work; Browser does not like the parameter
btn.Attributes.Add("onclick","disp_prompt(<%= e.Item.Cells[4] %>)");
[/B] }
}
Here's my Javascript
function disp_prompt(tablecell)
{
var number=prompt("Enter number","")
if (number!=null && number!="")
{
tablecell.value += number;
}
}
I have scoured several Javascript websites but couldn't find much help with Datagrids. Any help would be greatly appreciated.
Thanks
ktum