Jump to content

SelectedRow - GridView


madsovenielsen
 Share

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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...