NullReferenceException was unhandled by the user

混江龙づ霸主 提交于 2019-12-25 02:46:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!