Problem getting DataRowView.DataItem when editing a DataGrid row

H

Henri

Hi,

I'm using a DataGrid with ViewState disabled, so I rebind data after each
postback from the page's Sub OnLoad.
Inside one of the DataGrid column, there is a custom LinkButton to trigger a
Click event.
When this button is clicked, it displays a form (outside the datagrid) so
that the row can be edited.
The code is:

Sub row_Edit(sender As Object, e As EventArgs)
Dim link As LinkButton = CType(sender, LinkButton)
Dim row As DataGridItem = CType(link.NamingContainer, DataGridItem)
Dim view As DataRowView = CType(row.DataItem, DataRowView)

.....

End Sub

The problem is that row.DataItem is Nothing...
Why ?
As data is rebinded inside the page's OnLoad, and the linkbutton event is
triggered after, DataItem should be set...

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top