Hello Everyone,
I am trying out to fetch the Id of the item using ListView but it reports conversion error as
Conversion from string "" to type 'Integer' is not valid.
the code snippet is as follows
Code:
Protected Sub ListView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles ListView1.ItemCommand
con.Open()
If e.CommandName = "Play" Then
Dim Id As Integer = ListView1.DataKeys(e.CommandArgument).Values("Id")
End If
End Sub
But the same method for fetching Id with Gridview works fine.
Code:
Protected Sub GridView1_RowCommand1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
con.Open()
If e.CommandName = "play" Then
Dim Id As Integer = GridView1.DataKeys(e.CommandArgument).Values("Id")
End If
End Sub
I don't know about how to cast it properly.
Any suggestion is appreciated.
Thank You.