473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

FindByText not working

I have a screen that is trying to search a listbox both by FindByText
and FindByValue. The FindByValue is working find, but the FindByText is
not finding anything. This is even if I copy the text directly from the
source page and paste it into the textbox to make sure I have no typos.

Here is the screen:

************************************************** *****************
<%@Page Explicit="True" Language="VB" Debug="True" %>

<html>
<script runat="server">
Sub OK_Click(Sender As Object, E As EventArgs)
Dim Total, ItemIndex As Integer
Message.Text = "You chose:<br>"
Total = 1000
For ItemIndex = 0 To PCOptions.Items.Count -1
If PCOptions.Items(ItemIndex).Selected = True Then
Message.Text = Message.Text & _
PCOptions.Items(ItemIndex).Text & "<br>"
Total = Total + PCOptions.Items(ItemIndex).Value
End If
Next
Message.Text = Message.Text & "Your total is $" & Total
End Sub

Sub Find_Click(Sender As Object, E As EventArgs)
Dim FoundItem As ListItem

FoundItem = PCOptions.Items.FindByText(FindText.Text)
if Not isNothing(FoundItem) Then
Message2.text = FoundItem.text
else
Message2.text = "Nothing found for - " & FindText.Text
end if
End Sub

Sub Find_Click2(Sender As Object, E As EventArgs)
Dim FoundItem2 As ListItem

FoundItem2 = PCOptions.Items.FindByValue(FindText2.Text)
if Not isNothing(FoundItem2) Then
Message3.text = FoundItem2.text
else
Message3.text = "Nothing found for - " & FindText2.Text
end if
End Sub

</script>

<body>
<h1>Personalize Your PC</h1>
Thanks for deciding to purchase our choice,
one-of-a-kind Generic PC for a base price of only
$1000. Now you can pick from the following options
you'd like to add.<br>
<form runat="server">
<asp:listbox id="PCOptions" selectionmode="multiple"
runat="server">
<asp:listitem value="100">
CD-ROM Drive - $100</asp:listitem>
<asp:listitem value="200">
19 Inch Monitor - $200</asp:listitem>
<asp:listitem value="150">
Ink Jet Printer - $150</asp:listitem>
<asp:listitem value="50">
Joystick - $50</asp:listitem>
<asp:listitem value="100">
128MB More RAM - $100</asp:listitem>
</asp:listbox><br><br>
<asp:button id="OKButton" text="OK" runat="server"
onclick="OK_Click" /><br><br>
<asp:textbox id="FindText" runat="server" /> <asp:button
id="findButton" text="Find by text" runat="server"
onclick="Find_Click" /><br><br>
<asp:textbox id="FindText2" runat="server" /> <asp:button
id="findButton2" text="Find by value" runat="server"
onclick="Find_Click2" /><br><br>
<asp:label id="Message" runat="server" /><br>
<asp:label id="Message2" runat="server" /><br>
<asp:label id="Message3" runat="server" /><br>
</form>
</body>
</html>

************************************************** *****************

The routine at issue is the "Find_Click" routine. The "Find_Click2"
routine works fine.

I can't see where I have screwed up (but I'm sure I have - I just can't
seem to find it).

Thanks,

Tom.

Nov 18 '05 #1
0 1429

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: acko bogicevic | last post by:
I have combobox which is filled from database. Afterwords i will get a criteria for searching a combo by value. Hao can i make item in combo to be selected when value in combo match critiria....
0
by: Mark | last post by:
I have a dropdownlist that is dynamically populated. I want to make one of the items be selected by default based on PART of the text that is displayed. However, the FindByText method of the...
3
by: AK | last post by:
Hi, I am using FindByText method of dropdownlist to change the selected item in a dropdownlist like this: DropDownList1.Items("mySelectedText").Selected = True It doesn't seem to be doing...
5
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We...
5
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find...
9
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. ...
2
by: | last post by:
Hi, is it FindByText case Sensitive? How to set it to case insensitive? Thanks in advance.
1
by: tshad | last post by:
I have a dropdown that gives me an error when I do a FindByText, such as: Dim temp as ListItem = JobTitles.Items.FindByText("BarTender") temp.Selected = True or ...
4
by: Aneri | last post by:
How to use FindByText property of dropdownlist where text to find is in a textbox? i.e if i write, dropdownlist1.Items.FindByText(" ' "& txt1.Text &" ' ").Selected = True i get error ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.