I'm trying to get what seems like it should be a simple chunk of code to work, but I keep getting the ole Null Reference Exception...
Dim materialID As Integer = CInt(Request.QueryString("MaterialID"))
    Dim s As String = Nothing
    DBTable = MaterialStuff.GetMaterialHeader(materialID)
    Using DBTable
        s = CType(DBTable.Rows(0).Item("MaterialID"), String)
        Try
            If CType(DBTable.Rows(0).Item("MaterialID"), String) IsNot Nothing Then
                CType(MaterialIdControl, TextBox).Text = s
            Else
            End If
        Catch ex As NullReferenceException
            MsgBox(ex.ToString)
        End Try
    End Using
Here is where MaterialIdControl is coming from:
Dim MaterialIdControl As Control = FindControl("txtMaterial")
When stepping through it s is equal to 970 (970 is not a string I know but previous programmer messed up this program) Anyway, the right value is there but it's still saying that there is an exception, any idea where I can fix this at?
 
    