You should be checking to make sure that the row being bound is the Footer and not a Header or Data row. If you try to access a variable in the footer row when it isn't the footer row that is being bound then you'll have a problem.
For example:
-
Private Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles myGridView.RowDataBound
-
-
Select Case e.Row.RowType
-
Case DataControlRowType.Header
-
'In this case the header row is being bound
-
'All controls in the header row are accessible
-
Case DataControlRowType.DataRow
-
'In this case a Data Row is being bound
-
'All controls in the data row are accessible
-
Case DataControlRowType.Footer
-
'In this case the footer row is being bound
-
'All controls in the footer row are now accessible
-
Case DataControlRowType.Pager
-
'In this case the pager row is being bound
-
'All controls in the pager row are accessible
-
'....
-
End Select
-
-
End Sub
The controls available to you all depends on which row is currently being bound. If the row being bound is a data row, then obviously you wont find controls that are in the footer row.
When you use the findControl method you should always make sure that the control was found before you try to use it (check to make sure that the control IsNot Nothing before you try to use it)
-Frinny