Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
I am using combo box to show supplier name. In search facility when user type “S” in combo box the entire supplier’s list should be display whose name start form “S”, like country, state search facility in any web based application. Same way as per user inputs list should be change.
Can any one know logic behind this
Posted 1-Jan-13 19:59pm
Edited 10-Jul-13 4:05am
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to use autocomplete ajax extender. Look at this article for description and sample: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hey try to use autocomplete extender instead of Conbobox..
Refer Below Link.
AutoComplete extender[^]
ASP.Net Ajax AutoCompleteExtender Without Using Web Service[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

This funcionality is called auto-complete
first of all you will need this js file:
jquery-ui-1.8.20.custom.min.js
and css file:
jquery-ui-1.8.20.custom.css
 
1.place link of these files on page where you want to use auto-complete just like this:
 <script src="Scripts/jquery-ui-1.8.20.custom.min.js" type="text/javascript"></script>
    <link href="Styles/jquery-ui-1.8.20.custom.css" rel="stylesheet" type="text/css" />
 
2.then use this script:
    <script type="text/javascript">
        $(document).ready(function () {
            $('input[id$=textboxid]').autocomplete({
                source: function (request, response) {
                    $.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "pagename.aspx/getReason",
                        data: "{'keywords':'" + request.term + "'}",
                        dataType: "json",
                        async: true,
                        success: function (data) {
                            response(data.d);
                        },
                        error: function (result) {
                            //alert("Error");
                        }
                    });
                },
                minLength: 2
            });
 
        });
</script>
3.then add this method in code behind (.cs) file:
 [WebMethod]
    public static IList<string> getReason(string keywords)
    {
        int count = 0;
        IList<string> result = new List<string>();
        string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
        SqlConnection con1 = new SqlConnection(constr);
        SqlCommand cmd1 = con1.CreateCommand();
        cmd1.CommandText = "select distinct column_name from tablename where column_name like '%" + keywords + "%'";
        try
        {
            con1.Open();
            SqlDataReader dr = cmd1.ExecuteReader();
            while (dr.Read())
            {
                count++;
                result.Add(dr["column_name"].ToString());
                if (count == 100)
                    break;
            }
            con1.Close();
            return result;
        }
        catch
        {
            return null;
        }
    }
  Permalink  
v3

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 756
1 OriginalGriff 452
2 Tadit Dash 350
3 sanket saxena 329
4 Peter Leow 228
0 Sergey Alexandrovich Kryukov 11,890
1 OriginalGriff 7,335
2 Peter Leow 5,003
3 Abhinav S 3,943
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 10 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid