Here is a stored procedure I created in MySQL:
CREATE PROCEDURE `sp_find_food`(
IN search_string varchar(255)
)
BEGIN
DECLARE ss VARCHAR(257);
SET ss = CONCAT('%',sear ch_string,'%');
SELECT NDB_No,Long_Des c FROM food_des WHERE Long_Desc LIKE ss;
END
If I execute this within MySQL's Query Browser, passing a suitable
argument such as 'Butter', it works fine showing 151 unique records.
Obviously, I want to allow a user to provide a string representing
part of a food name and populate the dropdownlistbox with the items
returned.
Here is the definition of my datasource:
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:sr19Connecti onString %>"
ProviderName="< %$
ConnectionStrin gs:sr19Connecti onString.Provid erName %>"
SelectCommand=" CALL sp_find_food('@ ss')">
<SelectParamete rs>
<asp:ControlPar ameter
ControlID="sear ch_string" Name="@ss" PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>
Here is the textbox:
<asp:TextBox ID="search_stri ng"
runat="server" AutoPostBack="T rue"></asp:TextBox></td>
And here is the dropdownlistbox :
<asp:DropDownLi st ID="DropDownLis t1"
runat="server" AutoPostBack="T rue" DataSourceID="S qlDataSource1"
DataTextField=" Long_Desc"
DataValueField= "NDB_No" Width="100%">
</asp:DropDownLis t></td>
I used a pattern like that which I used to determine the items in one
dropdownlistbox from the selected item in another. That worked fine,
because, I think, the AutoPostBack-true setting resulted in the
dependant dropdownlistbox to be recomputed each time a new item is
selected. I assumed there is an analogous event that happens whever a
new value is entered into the textbox.
Unfortunately, my dropdown listbox connected to the textbox is NEVER
populated. Why? How do I get this to work?
Thanks
Ted 1 2290
Howdy Ted,
You code seems to be OK. I do not have MySQL server installed so i could not
test it properly, however i replaced sqldatasource with objectdatasourc e and
everything works like a charm, when text changes, page is automatically
posted back to server, and drop down list is populated with new values.
Therefore my quess would be sqldatasource is not retrieving any results at
all. To find out if this is the case, perform select manually to test for any
result:
System.Collecti ons.IEnumerable results = SqlDataSource1. Select();
Hope this helps
--
Milosz
"Ted" wrote:
Here is a stored procedure I created in MySQL:
CREATE PROCEDURE `sp_find_food`(
IN search_string varchar(255)
)
BEGIN
DECLARE ss VARCHAR(257);
SET ss = CONCAT('%',sear ch_string,'%');
SELECT NDB_No,Long_Des c FROM food_des WHERE Long_Desc LIKE ss;
END
If I execute this within MySQL's Query Browser, passing a suitable
argument such as 'Butter', it works fine showing 151 unique records.
Obviously, I want to allow a user to provide a string representing
part of a food name and populate the dropdownlistbox with the items
returned.
Here is the definition of my datasource:
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:sr19Connecti onString %>"
ProviderName="< %$
ConnectionStrin gs:sr19Connecti onString.Provid erName %>"
SelectCommand=" CALL sp_find_food('@ ss')">
<SelectParamete rs>
<asp:ControlPar ameter
ControlID="sear ch_string" Name="@ss" PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>
Here is the textbox:
<asp:TextBox ID="search_stri ng"
runat="server" AutoPostBack="T rue"></asp:TextBox></td>
And here is the dropdownlistbox :
<asp:DropDownLi st ID="DropDownLis t1"
runat="server" AutoPostBack="T rue" DataSourceID="S qlDataSource1"
DataTextField=" Long_Desc"
DataValueField= "NDB_No" Width="100%">
</asp:DropDownLis t></td>
I used a pattern like that which I used to determine the items in one
dropdownlistbox from the selected item in another. That worked fine,
because, I think, the AutoPostBack-true setting resulted in the
dependant dropdownlistbox to be recomputed each time a new item is
selected. I assumed there is an analogous event that happens whever a
new value is entered into the textbox.
Unfortunately, my dropdown listbox connected to the textbox is NEVER
populated. Why? How do I get this to work?
Thanks
Ted
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: A P |
last post by:
Hi!
I have seen some techniques like this on the web. Currently, I'm using Combo
box which values came from database table. One disadvantage is when the
combo box have lots of values, users are complaining since you cannot use
keyboard to search the value that is needed. Hope you might help me.
regards,
Me
|
by: Scott |
last post by:
The code below appears to work on the following:
MAC - Safari
PC - IE
PC - Opera
But the addition of items to the dropdown (select2) does not function
in:
MAC – IE
|
by: Bob Quintal |
last post by:
I have a combobox on a form that contains titles of categories, one
of which is to be assigned to a record.
I'd like to show users some notes on each category to aid in the
selection decision, but I can't find a way to determine which row
is highlighted.
I tried using the mouseover event to return the .listindex value
and update the notes textbox, but that returns null unless the row
is selected by clicking or typing in the start of...
|
by: John R. |
last post by:
I want to have a listbox that shows a checkbox and a textbox.
I created a user control that has a checkbox and a textbox in it and have
been trying to add it to a listbox but I can't get it to show up for each
item I add to the listbox.
foreach (Column column in columns)
{
ColumnsListBox.Items.Add(column.Name);
ColumnsListBox.Controls.Add(new ColumnListControl(true, column.Name,
|
by: Kay |
last post by:
Hello,
I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then...
| |
by: Valerian John |
last post by:
I have a ListBox webcontrol on an aspx page. Items are added to the
ListBox using client-side code. However, when the page is posted back the
items are missing/not available. (It is like the page does not know the
items were added client-side.)
TIA,
Val
|
by: Ryan Ternier |
last post by:
Thanks for the previous help guys!
I got my list box issue working, but now i'm trying to loop through all the
items in my page.
I want to find each listbox, once I do i strip the ID down to find what I
need so I can populate a DB.
lstTest is dim'd as a ListBox, and I thought I could just do:
|
by: Mike Collins |
last post by:
I cannot get the correct drop down list value from a drop down I have on my
web form. I get the initial value that was loaded in the list.
It was asked by someone else what the autopostback was set to...it is set to
false.
Can someone show me what I am doing wrong and tell me the correct way? Thank
you.
In the page load event, I am doing the following:
|
by: John |
last post by:
I have a listbox that is databound when my form loads. A user
can then select and option using a drop down box. When the user
selects an option the corresponding items in the listbox gets selected.
How can I show those selected items at the top of my listbox. The
issue is when the user selects an item and it is in the middle of the list,
the user is not able to know an item it is selected or not unless they scroll
through the listbox.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |