Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
<!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
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 20-Mar-13 21:33pm
Edited 20-Mar-13 21:48pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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,
  Permalink  
Comments
supriya931 at 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 at 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)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web02 | 2.8.1411022.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100