Click here to Skip to main content
15,883,922 members
Please Sign up or sign in to vote.
1.57/5 (3 votes)
Hello Friends,
I want to implement textbox autocomplete list from gridview data in same page by using javascript or jquery.
Posted
Updated 25-Sep-14 20:07pm
Comments
Ok, so what is the issue?
[no name] 26-Sep-14 2:46am    
where is your code what ever you tried

1 solution

1)Convert Grid as DataTable or View
2)write weservice to read data from gridDataTable
3)call the web service in jasaon method

XML
<script type="text/javascript">
    $(document).ready(function () {
        $("#<%=txtSearch.ClientID %>").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("~/Service.asmx/GetCustomers") %>',
                    data: "{ 'prefix': '" + request.term + "'}",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                label: item.split('-')[0],
                                val: item.split('-')[1]
                            }
                        }))
                    },
                    error: function (response) {
                        alert(response.responseText);
                    },
                    failure: function (response) {
                        alert(response.responseText);
                    }
                });
            },
            select: function (e, i) {
                $("#<%=hfCustomerId.ClientID %>").val(i.item.val);
            },
            minLength: 1
        });
    });
</script>
 
Share this answer
 

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