Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to type some text in textbox based on that text box value dropdownlist value should be select.in my dropdown values are coming from database.
please help me.give me logic

What I have tried:

i have tried to use dropdownlistextender using ajax but not working
Posted
Updated 12-Jul-16 3:39am
Comments
Karthik_Mahalingam 12-Jul-16 9:19am    
try using javascript/jquery
AnvilRanger 12-Jul-16 9:52am    
Are you talking about using autocomplete like https://jqueryui.com/autocomplete/?
If not your design sounds very odd, using a free form textbox to select the value from a defined list in the dropdown.

I have not clearly understood from sentence you posted.if you want to select dropdownlist item based on text entered on textbox ,in asp.net webform you can use textchanged event.
Code will look something like this
C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
      {
          if (TextBox1.Text == "xyz")
              DropDownList1.SelectedValue = "0";
      }

in aspx something like this\..
ASP.NET
<div>
        <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
    
    </div>
        <asp:DropDownList ID="DropDownList1" runat="server">
        </asp:DropDownList>

you can use update panel if you want to stop postback
 
Share this answer
 
try this using javascript

HTML
<html>
<head>
    <script>
        function selectValue(e, value) {
            var ddl = document.getElementById('<%= DropDownList1.ClientID %>');
            for (var i = 0; i < ddl.options.length; i++) {
                if (ddl.options[i].text == value) {
                    ddl.options[i].selected = true;
                }
            }
        }
    </script>

</head>
<body>

    <form id="form1" runat="server">

        <asp:TextBox ID="TextBox1" onkeyup="selectValue(event,value)" runat="server"></asp:TextBox>
        <asp:DropDownList ID="DropDownList1" runat="server">
        </asp:DropDownList>
    </form>

</body>
</html>
 
Share this answer
 
Comments
Pragya Nagwanshi 26-Jul-16 2:53am    
Thanks all of u guyz.I did it
Karthik_Mahalingam 26-Jul-16 4:23am    
working?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900