问题
I have this form on VS2012. This dropdownlist exists only in the Edit Template. I am trying to pass the value(strLibName) to this list as the selected value. This value is coming from the previous screen. I do get the count of 3 when I debug but sill it throws the error on the selected value line.I need some direction on how to get this problem resolved.
3:30pm - I don't get the error anymore, but the value is not being passed on to the control. The control ddLib still has the first value selected.
Thanks
VB.NET Code:
Protected Sub frmUpdateIncident_DataBound(sender As Object, e As EventArgs) Handles frmUpdateIncident.DataBound
Dim ddLib As DropDownList
ddLib = DirectCast(frmUpdateIncident.FindControl("ddLibrary"), DropDownList)
If ddLib IsNot Nothing Then
If ddLib.Items.Count > 0 Then
If strLibName IsNot Nothing Then
ddLib.SelectedValue = strLibName
End If
End If
End If
End Sub
来源:https://stackoverflow.com/questions/20804703/nullreferenceexception-was-unhandled-by-the-user