This method adds a javascript method to marks text box onkeydown, that javascript method takes the rowindex as argument. This code is being converted from C#. The method works fine using C#, but I got a “Conversion from string "javascript: DoPostBackWithRowInd" to type 'Double' is not valid “message when using the VB code below. Please help!
<script type="text/javascript" language="javascript">
function DoPostBackWithRowIndex(rowIndex) {
if (document.getElementById('<%=HdnSelectedRowIndex.ClientID%>') != null) {
document.getElementById('<%=HdnSelectedRowIndex.ClientID%>').value = rowIndex;
}
return true;
}
</script>
'Event to handle the Users Grid DataBound Event
'This method adds a javascript method to marks text box onkeydown, that javascript method takes the rowindex as argument.
Protected Sub GvUsersRowDataBound(ByVal sender As Object, ByVal eventArgs As GridViewRowEventArgs)
If (eventArgs.Row.RowType = DataControlRowType.DataRow) Then
Dim TxtMarks As TextBox = CType(eventArgs.Row.FindControl("TxtMarks"), TextBox)
TxtMarks.Attributes.Add("onkeydown", "javascript:return DoPostBackWithRowIndex('" + eventArgs.Row.RowIndex + "');")
End If
End Sub