I am looking to store the value from the selected record in a GridView so that I can Navigate to a new page with this as a session variable.
I have tried many variations of the code (held in the master page) but get a variation of issue. The simplified version of the code below returns and issue that GridView1 is not declared. As you can see from the Sub my gridview is called Grid view1. If I uncomment the Dim statement for Gridview1 and run the screen i get "Exception Details: System.NullReferenceException: Object reference not set to an instance of an object"
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
' Dim
Gridview1 As GridView
Dim NewText As String
NewText = GridView1.Cells(0)
Session("Table_ID") = NewText
Response.Redirect(
"../Newpage.aspx")
End Sub
I have also tried variations on what to put in place of the system.EventsArgs and replacing
"NewText = GridView1.Cells(0)"
with
"NewText = e.item.Cells(0)"
as I have seen e.item in other examples but the item does not seem to be a member of System.EventArgs or the other variations I use (i.e GridViewCommandEventArgs)
However DataGridItemEventArgs does allow e.items.Cells(0) but returns the error that it " does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs) "
Any advice would be most greatfully recieved