Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i use the auto suggest box without web serivce it reteriving the value from the database properly but it will not show the list on the web page.
can any one help me
here is my html code
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
<div>
    &nbsp;<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </cc1:ToolkitScriptManager>
    &nbsp;
<asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
    <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"  TargetControlID="txtCountry"
MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="1000" ServiceMethod="GetCountries" >
    </cc1:AutoCompleteExtender>
</div>
    </form>
</body>
</html>
and it is my code
VB.NET
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Configuration
Partial Class Default2
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    <system.web.script.services.scriptmethod()> _
<system.web.services.webmethod()> _
Public Shared Function GetCountries(ByVal prefixText As String) As List(Of String)
        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("appraisalConnectionString").ToString())
        con.Open()
        Dim cmd As New SqlCommand("select * from tblCountry where CountryName like @Name+'%'", con)
        cmd.Parameters.AddWithValue("@Name", prefixText)
        Dim da As New SqlDataAdapter(cmd)
        Dim dt As New DataTable()
        da.Fill(dt)
        Dim CountryNames As New List(Of String)()
        For i As Integer = 0 To dt.Rows.Count - 1
            CountryNames.Add(dt.Rows(i)(1).ToString())
        Next
        Return CountryNames
    End Function
End Class
Posted
Updated 20-Mar-13 20:48pm
v2

1 solution

Hello Supriya,

Try increasing CompletionSetCount. As per documentation the signature of the Service method should be as shown below.
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public string[] GetCompletionList(string prefixText, int count)

I will also recommend you to go through this[^] article.

Regards,
 
Share this answer
 
Comments
supriya931 21-Mar-13 3:00am    
it will not shoe the data in list on page
it fectching from database but not shoe in list
Prasad Khandekar 21-Mar-13 3:26am    
Try to test in FireFox. See if you get any errors in Error Console(Ctrl + Shift + J), Or in Script Tab of IE Developers Tool.

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