Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   NullReferenceException error on GridView rows loop (http://www.velocityreviews.com/forums/t763078-nullreferenceexception-error-on-gridview-rows-loop.html)

mharness 12-07-2006 03:45 PM

NullReferenceException error on GridView rows loop
 
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




All times are GMT. The time now is 08:55 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.