Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > NullReferenceException error on GridView rows loop

Thread Tools

NullReferenceException error on GridView rows loop

Posts: n/a

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"



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"),
If chkSelected Then
ProjectID = CType(row.FindControl("ProjectID"), Label).Text
End If
End Sub

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Hide the Gridview Rows and Header rows in Button click VijayRama ASP .Net 2 10-12-2009 01:58 PM
trying to loop through rows in gridview. Paul ASP .Net 2 05-21-2008 06:36 PM
UserControl with Gridview: Set DataSource: NullReferenceException OJ ASP .Net 7 04-28-2006 05:02 PM
help: loop within a loop -how to display data in 3 columns by 4 rows format addi ASP General 0 12-31-2003 04:31 AM