Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript-vb在选中gridview中某行的复选框后获取该行的值,以避免每次选择时刷新页面_Javascript_Asp.net_Vb.net - Fatal编程技术网

使用javascript-vb在选中gridview中某行的复选框后获取该行的值,以避免每次选择时刷新页面

使用javascript-vb在选中gridview中某行的复选框后获取该行的值,以避免每次选择时刷新页面,javascript,asp.net,vb.net,Javascript,Asp.net,Vb.net,我在evryrow上有一个带有复选框的aspx gridview,需要的是每当我们检查任何一行时,都应该启动一个查询,以将特定的代理-每行包括代理、通行证、状态-更改为付费状态。使用javascript 我需要知道的是如何循环以获取选中行和获取选中行的ID,这样我就可以获取该行中代理的ID,以便更新其状态。使用javascript 我在stackflow上发现了类似的东西: 多谢各位 但这不是我的情况,需要的是在选中一个复选框时,javascript函数应该启动,通过该复选框,我可以在拥有这一

我在evryrow上有一个带有
复选框的aspx gridview
,需要的是每当我们检查任何一行时,都应该启动一个
查询
,以将特定的代理-每行包括
代理、通行证、状态-更改为付费状态
。使用javascript

我需要知道的是
如何循环以获取选中行
获取选中行的ID
,这样我就可以获取该行中代理的ID,以便更新其状态。使用javascript

我在stackflow上发现了类似的东西: 多谢各位

但这不是我的情况,需要的是在选中一个复选框时,javascript函数应该启动,通过该复选框,我可以在拥有这一行的索引和这一切之后更新网格视图中的选定行,以避免刷新页面


关于

您可以这样尝试……查找行索引

Private Function getCellControl(ByVal , As rowIdx, ByVal Unknown As colIdx) As function
    Dim gridCell As var = getGridColumn(rowIdx, colIdx)
    Dim type As var = Nothing
    Dim typePos As var
    Dim ctrId As var
    Dim idPos As var
    Dim delPos As var
    Dim inHTML As var
    Dim buf As var
    Dim chkStatus As var
    Dim statPos As var
    If (Not (gridCell) Is Nothing) Then
        inHTML = gridCell.innerHTML
        typePos = inHTML.indexOf("type")
        If (typePos > 0) Then
            typePos = (typePos + 5)
            buf = inHTML.substring(typePos)
            delPos = buf.indexOf(" ")
            If (delPos > 0) Then
                type = inHTML.substring(typePos, (typePos + delPos))
                If (type = "checkbox") Then
                    idPos = inHTML.indexOf("id")
                    If (idPos > -1) Then
                        idPos = (idPos + 3)
                        ctrId = inHTML.substring(idPos, (typePos - 5))
                    End If
                    statPos = buf.indexOf(" ")
                    If (statPos > -1) Then
                        buf = buf.substring((statPos + 1))
                        delPos = buf.indexOf(" ")
                        chkStatus = buf.substring(0, delPos)
                    End If
                End If
            End If
        End If
    End If
    Return ctrId
End Function

您可以使用jQuery执行此操作:

$("#<%=GridView1.ClientID%> input[type='checkbox']").click(function(){
    if ($(this).is(":checked")){
        alert($(this).closest("tr").attr("id"));
    }
});
$(“#输入[type='checkbox']”)。单击(函数(){
如果($(this).is(“:checked”)){
警报($(this).closest(“tr”).attr(“id”);
}
});

您尝试过什么?您在流程的哪一部分遇到了阻碍?感谢您的合作,但是您是如何将私有函数getCellControl(ByVal,作为rowIdx,ByVal未知作为colIdx)编写为函数的?每当我将此代码转换为vb.net时,会出现意外的EOF错误,您是如何声明此函数的,我真正需要的是如何在javascript中获取cntrlID。谢谢