0

I have aspx gridview with checkbox on evryrow, what is required is whenever we check any of the rows, a query should be launched to change the specific agent -each row consist of agentID, Pass, Status- to Paid Status. using javascript

What I need to know is how to loop to get the Checked row and get the ID of the row checked so that I can get THe ID of the Agent in thos row so that I can update its status.using javascript

I found something similar on stackflow: Thank you

Get GridView selected row DataKey in Javascript

But it is not my case, what is needed is at the check of a checkbox a javascript function should launch through which I could update the selected row in grid view after having the index of this row and this all to avoid refreshing the page.

Regards

1
  • And what have you tried? On what part of the process are you stucked?
    – Icarus
    Oct 28, 2011 at 14:01

2 Answers 2

0

you could try like this.....for finding the row index ...

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
1
  • thank you for your cooperation but how did you write private Function getCellControl(ByVal , As rowIdx, ByVal Unknown As colIdx) As function whenever I translate this code to vb.net an unexpected EOF error appears, how did you declare this function, and what I really need is how to get cntrlID in javascript.Thank you
    – nour
    Oct 29, 2011 at 7:31
0

You could do this with jQuery:

$("#<%=GridView1.ClientID%> input[type='checkbox']").click(function(){
    if ($(this).is(":checked")){
        alert($(this).closest("tr").attr("id"));
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.