Results 1 to 2 of 2

Thread: Get index of the gridview row when clicks on linkbutton

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    fgh
    Posts
    332

    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 ... ???
    gh

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    fgh
    Posts
    332

    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
    gh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width