Problem getting DataRowView.DataItem when editing a DataGrid row

Discussion in 'ASP .Net' started by Henri, Aug 3, 2004.

  1. Henri

    Henri Guest

    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
     
    Henri, Aug 3, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MS
    Replies:
    0
    Views:
    3,219
  2. Bazza Formez
    Replies:
    4
    Views:
    405
    Vanni Tomezzoli
    Dec 9, 2004
  3. Replies:
    3
    Views:
    2,434
  4. Andrew Jocelyn
    Replies:
    2
    Views:
    1,528
    Allen Chen [MSFT]
    Apr 27, 2009
  5. Rob Wire

    How to check if CType(e.Item.DataItem, DataRowView) is DBNULL

    Rob Wire, Jul 29, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    193
    Rick Rainey[MSFT]
    Jul 30, 2003
Loading...

Share This Page