Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

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

0
kdeutsch
Asked:
kdeutsch
  • 2
  • 2
  • 2
1 Solution
 
waltersnowslinarnoldCommented:
Use the following condition..,

lbPers.items IS NULL
0
 
kdeutschAuthor Commented:
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.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Well, looking at your code, testing for zero items won't work anyway because you are always forcing a fixed initial value (unless your buildDD method is clearing it again), so you should actually be testing:

    If lbPers.Items.Count == 1 Then        '// This indicates that there is nothing but the fixed initial value
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
waltersnowslinarnoldCommented:
You can use lbPers.Items = null instead.
0
 
kdeutschAuthor Commented:
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.
0
 
Carl TawnSystems and Integration DeveloperCommented:
Ah yes, sorry, should have been a single =.     Put it down to a bit of C# to VB cross-over :o)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now