Gridview 从数据绑定链接按钮检索行索引

Gridview 从数据绑定链接按钮检索行索引,gridview,Gridview,在rowdatabound事件中,我在某些单元格中放置了链接按钮 我想不出单击时如何从中检索行索引值。我在下面的几个变体中对链接按钮进行了编码 If e.Row.RowType = DataControlRowType.DataRow Then Dim ParentLink As LinkButton = New LinkButton If (e.Row.Cells(3).Text.Equals(" ")) Then e.

在rowdatabound事件中,我在某些单元格中放置了链接按钮

我想不出单击时如何从中检索行索引值。我在下面的几个变体中对链接按钮进行了编码

If e.Row.RowType = DataControlRowType.DataRow Then
        Dim ParentLink As LinkButton = New LinkButton
        If (e.Row.Cells(3).Text.Equals(" ")) Then
            e.Row.Cells(3).BackColor = Drawing.Color.Red
            ParentLink.Text = "Resend"
            ParentLink.ID = "Resend"
            ParentLink.CommandName = "Resend"
            ParentLink.CommandArgument = e.Row.RowIndex.ToString()
            '  AddHandler ParentLink.Command, AddressOf resend_email
            e.Row.Cells(5).Controls.Add(ParentLink)
        End If
    End If

我见过使用“asp:TemplateField>”的例子,但在以这种方式添加时没有很好的例子。当我单击时,它返回到rowdatabound事件,但我不知道如何获取linkbutton的commandargument或rowindex。让这个年轻人看看他的错误

最后一段有效的代码片段

 Sub CustomersGridView_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    If e.CommandName = "Resend" Then
        Dim rowIndex = Convert.ToInt32(e.CommandArgument)
        Dim Row = GridView1.Rows(rowIndex)
        loc_resend = Row.Cells(4).Text ' location
        custid_resend = Row.Cells(0).Text ' customer id
        name_resend = Row.Cells(1).Text ' customer name
        Ckbox_resend.Visible = True
        butResend.Visible = True
    End If
End Sub