User2103319870 posted
I need to retrieve the datakeynames from a line of a listview hitting a button.
I'm using VB.net in a webform.
If you have a click event attached to the button then you can use the below code to get the datakey value of current selected item
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Get the selected listview item
Dim item As ListViewItem = TryCast(TryCast(sender, Button).NamingContainer, ListViewItem)
'Get the datakey from listview
'Change the listview id and datakey name here
Dim idvalue As Integer = CInt(ListView1.DataKeys(item.DataItemIndex).Values("YourDataKeyName"))
End Sub