开发者

JavaScript to retrieve value from Grid

I have a RowDataBound event as follows.

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;");
    } 
}

When this event fires, I am getting the following error开发者_JAVA技巧:

object element not found or not an object

Why am I getting this error?


I would recommend you to use the jQuery library or any other javascript framework to make your life a LOT easier.

This errors seems to me that you either can't find the object you are looking for or the property cells does not exist. This might even differ from browser to browser ...

Have a look at your generated code and see what the ID of that error is ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜