Get index of the gridview row when clicks on linkbutton
Hello,
I have a gridview with a linkbutton as template field. I need to get the row index of the link button clicked inside the gridview. Currently i am using the below code to extract,
Protected Sub lnkCancel_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim lnk As LinkButton = DirectCast(sender, LinkButton)
lnk.ToolTip = "1"
Dim index As Integer = 0
Dim i As Integer = 0
For Each row As GridViewRow In gridListNames.Rows
Dim lnkBut As LinkButton = DirectCast(row.FindControl("lnkCancel"), LinkButton)
If lnkBut.ToolTip & "" Then
index = i
Exit For
End If
i += 1
Next
lnk.ToolTip = ""
Dim lnkCanc As LinkButton = DirectCast(gridListNames.Rows(index).Cells(2).FindControl("lnkCancel"), LinkButton)
End Sub
Is there any simple code to get the row index of the link button clicked ... ???
Re: Get index of the gridview row when clicks on linkbutton
Quote:
Originally Posted by sureshvijayan
Hello,
I have a gridview with a linkbutton as template field. I need to get the row index of the link button clicked inside the gridview. Currently i am using the below code to extract,
Protected Sub lnkCancel_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim lnk As LinkButton = DirectCast(sender, LinkButton)
lnk.ToolTip = "1"
Dim index As Integer = 0
Dim i As Integer = 0
For Each row As GridViewRow In gridListNames.Rows
Dim lnkBut As LinkButton = DirectCast(row.FindControl("lnkCancel"), LinkButton)
If lnkBut.ToolTip & "" Then
index = i
Exit For
End If
i += 1
Next
lnk.ToolTip = ""
Dim lnkCanc As LinkButton = DirectCast(gridListNames.Rows(index).Cells(2).FindControl("lnkCancel"), LinkButton)
End Sub
Is there any simple code to get the row index of the link button clicked ... ???
Oh! sorry, wrong forum.... let me post it to asp.net