Jump to content

SelectedRow - GridView


Recommended Posts

HelloI have some data in a Gridview, selection is enabled, i need to be able to select a row and get the content of the first cell from that row. Here is the code:

	Public Sub codeGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.RowCommand		Dim row As GridViewRow = GridView1.SelectedRow		Response.Write(row.Cells(1).Text)	End Sub

I have this property set in the GridView control:

onselectedindexchanged="codeGridView_SelectedIndexChanged"

There is no errors in the IDE but when i try to select a row the browser quits and i get this error in the IDE:

NullReferenceException was unhandled by user code.Object reference not set to an instance of an object.

Whats wrong ?Any help is greatly appreciated.Kind regards Mads Nielsen

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...