0
我有一个数据网格。它的第一列是ClientType。在单击第一列中的每个单元即ClientType时,该值将显示在名为txtClientType的文本框中。为此我使用了下面的代码。关于单元格在数据网格中点击
Private Sub dtGridsearch_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dtGridsearch.ItemDataBound
Dim lt As ListItemType = e.Item.ItemType
If lt = ListItemType.Item Or lt = ListItemType.AlternatingItem Then
Dim currentCell As TableCell = CType(e.Item.Controls(0), TableCell)
dtGridsearch.Columns(0).InitializeCell(currentCell, 0, ListItemType.Item)
Dim s As New System.Web.UI.WebControls.Style
s.CssClass = "Hyp"
Dim str As String = CType(e.Item.DataItem, DataRowView).Row(1)
currentCell.ApplyStyle(s)
currentCell.Attributes.Add("OnClick", "javascript:PassBack('" & CType(e.Item.DataItem, DataRowView).Row(0) & "','" & str.Trim & "');")
End If
End Sub
在javascript中我用下面的代码结合值的文本框
function PassBack(FieldId,FieldValue)
{
document.getElementById(txtClientType).value = FieldValue;
}
上述代码在IE。但是在Chrome中,当单击datagrid中的单元格时,相应的值不会显示在文本框中。我正在使用VS2008。可能是什么原因?