I have placed a link-button in certain cells while in rowdatabound event.
I cant though figure out how to retrieve the row index value from it when clicked. I have coded the link button in several variations of below.
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
I have seen using "asp:TemplateField>", but no good examples when adding one this way. When I click it comes back to the rowdatabound event, but I don't know how to get the commandargument or rowindex of the linkbutton. Show this young lad the error of his ways!
Final code snippet that worked.