NullReferenceException error on GridView rows loop

Discussion in 'ASP .Net Datagrid Control' started by mharness, Dec 7, 2006.

  1. mharness

    mharness Guest

    Hello,

    I'm trying to do something in a gridview that I've previously done in a
    datagrid and can't figure out why it won't work here.

    The code will loop through the gridview properly when there is no reference
    to chkSelected and ProjectID but when they are referenced I'm getting a
    NullReferenceException error (regardless of whether I use the "new"
    keyword).

    Thanks,

    Mike

    Protected Sub RemoveSelectedProjects()
    Dim myGridView As GridView
    Dim ProjectID As New Integer
    Dim chkSelected As Boolean
    myGridView = Me.gvRequestProjects
    Dim row As GridViewRow
    For Each row In myGridView.Rows
    chkSelected = CType(row.FindControl("chkSelected"),
    CheckBox).Checked
    If chkSelected Then
    ProjectID = CType(row.FindControl("ProjectID"), Label).Text
    RemoveProject(ProjectID)
    End If
    Next
    End Sub
    mharness, Dec 7, 2006
    #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. OJ
    Replies:
    7
    Views:
    7,942
    Shaun McDonnell
    Apr 28, 2006
  2. Paul
    Replies:
    2
    Views:
    9,705
  3. VijayRama
    Replies:
    2
    Views:
    2,298
    Gregory A. Beamer
    Oct 12, 2009
  4. addi
    Replies:
    0
    Views:
    263
  5. Isaac Won
    Replies:
    9
    Views:
    354
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page