用于从Grid检索值的JavaScript

时间:2009-12-07 06:37:18

标签: javascript

我有一个RowDataBound事件,如下所示。

protected void GridLedger_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow) 
    {
        e.Row.Attributes.Add("onMouseDown", "var str = document.getElementById('" + e.Row.ClientID + "').cells[0].innerText; document.getElementById('<%=TextBox1.ClientID%>').value = str;");
    } 
}

当此事件触发时,我收到以下错误:

object element not found or not an object

为什么我收到此错误?

1 个答案:

答案 0 :(得分:0)

我建议你使用jQuery库或任何其他javascript框架,让你的生活更轻松。

在我看来,您无法找到您要查找的对象或属性单元格不存在。这甚至可能因浏览器而异......

查看生成的代码,看看该错误的ID是什么......