T
tshad
I am getting an error on my Dropdownlist box if there is nothing in it when
I double click on the item I want to look at. I have the ddl setup to allow
double clicks on the items to look at like so:
Me.StoredSearches.Attributes("ondblClick") =
"__doPostBack('LbxSender','')"
If Request.Form("__EVENTTARGET") = "LbxSender" Then
Dim strSelected As String
strSelected = StoredSearches.SelectedItem.Value.ToString
Call SelectSearch(strSelected)
trace.warn("storedSearches.SelectedItem is nothing")
End If
If there is nothing in the box and you double click anywhere, you get the
following error:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
If there is at least one item in the ddl and you haven't already selected
anything, you will get the next index after the last item. For example, if
there is 1 item in the ddl (which would be index 0), you will get 1.
If there is nothing, in the box - you get the error:
I can fix it by doing this:
If Request.Form("__EVENTTARGET") = "LbxSender" Then
Dim strSelected As String
if not storedSearches.SelectedItem is nothing then
strSelected = StoredSearches.SelectedItem.Value.ToString
Call SelectSearch(strSelected)
else
trace.warn("storedSearches.SelectedItem is nothing")
end if
End If
All I do is check if "storedSearches.SelectedItem" (my dropdownlist) is
nothing.
I would have thought that I would get a -1 as an index.
If there is nothing in the ddl and you double click and you get null
(nothing) for the selectedItem, why wouldn't you get the same for selecting
an item past the list?
Thanks,
Tom
I double click on the item I want to look at. I have the ddl setup to allow
double clicks on the items to look at like so:
Me.StoredSearches.Attributes("ondblClick") =
"__doPostBack('LbxSender','')"
If Request.Form("__EVENTTARGET") = "LbxSender" Then
Dim strSelected As String
strSelected = StoredSearches.SelectedItem.Value.ToString
Call SelectSearch(strSelected)
trace.warn("storedSearches.SelectedItem is nothing")
End If
If there is nothing in the box and you double click anywhere, you get the
following error:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
If there is at least one item in the ddl and you haven't already selected
anything, you will get the next index after the last item. For example, if
there is 1 item in the ddl (which would be index 0), you will get 1.
If there is nothing, in the box - you get the error:
I can fix it by doing this:
If Request.Form("__EVENTTARGET") = "LbxSender" Then
Dim strSelected As String
if not storedSearches.SelectedItem is nothing then
strSelected = StoredSearches.SelectedItem.Value.ToString
Call SelectSearch(strSelected)
else
trace.warn("storedSearches.SelectedItem is nothing")
end if
End If
All I do is check if "storedSearches.SelectedItem" (my dropdownlist) is
nothing.
I would have thought that I would get a -1 as an index.
If there is nothing in the ddl and you double click and you get null
(nothing) for the selectedItem, why wouldn't you get the same for selecting
an item past the list?
Thanks,
Tom