Link to home
Start Free TrialLog in
Avatar of kdeutsch
kdeutschFlag for United States of America

asked on

Get the return of a listbox

I am try9ing to see if a list box retuns anything, so that I can send a message tot he user that nothing was found.

I have tried theses
lbPers.items.counts  = 0
lbPers.items = 0
lbpers.itmes.counts = ""


If txtSearch.Text = "" Then
            RegisterClientScriptBlock("showMessage", "<script language=""JavaScript""> alert('Type in a Personnel Name First.'); </script>")
        Else
            sql = "Select Distinct strSSN, strName + '|' + Substring(strSSN, 6,9) from tblPermTask where strname like '" & Name & "%' " _
                & "Order by strName + '|' + Substring(strSSN, 6,9), strSSN"
           
            lbPers.Items.Add(New ListItem("Click Person to Add", "0"))
            buildDD(sql, lbSoldier)
        End If

        If lbPers.Items = 0 Then
            RegisterClientScriptBlock("showMessage", "<script language=""JavaScript""> alert('Personnel does not currently have any Issues.'); </script>")
        End If

        txtSearch.Text = ""

Open in new window

Avatar of waltersnowslinarnold
waltersnowslinarnold
Flag of India image

Use the following condition..,

lbPers.items IS NULL
Avatar of kdeutsch

ASKER

Hi,
Still using asp.net 1.1 and IS NULL or ISNULL of DBNULL are all incorrect and give blue underlines, never been able to solve that one.
ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use lbPers.Items = null instead.
carl_tawn
Ok the == did not work for me but the follwoing did
If lbPers.Items.Count <= 1 Then

You got me think that my count really starts at 2 because I add in the click even to check that they picked on a person.
Ah yes, sorry, should have been a single =.     Put it down to a bit of C# to VB cross-over :o)