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
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