NullReferenceException error on GridView rows loop

M

mharness

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
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top