It doesn't say that datatable is nothing
Your ddlJuniors is probably nothing and accessing ddlJuniors.DataSource fails.
If dtPersons.Rows.Count > 0 Then
If (e.Row.RowType = DataControlRowType.DataRow) Then
Dim ddlTemp As DropDownList = DirectCast(e.Row.FindControl("ddlJuniors"), DropDownList)
ddlTemp.DataTextField = "USERN"
ddlTemp.DataValueField = "USERID"
ddlTemp.DataSource = dtPersons
ddlTemp.DataBind()
End If
End If
Not this code works as follows:
- find in the grid control named ddlJuniors
- assign the found control to local name ddlTemp <-- this can be anything you could call it dasfalksadfj and it would still work
- work with <u>that exact</u> reference through the function
You cannot assign ddlTmp and then try to use ddlJuniors later in the function.