Use Below Code to show data in Textbox in Asp.net :
<System.Web.Script.Services.ScriptMethod(), System.Web.Services.WebMethod()>
Public Shared Function SearchUnit(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim con As SqlConnection = New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("MTechSqlDatabaseConnectionString").ConnectionString
Dim cmd As SqlCommand = New SqlCommand
cmd.CommandText = String.Format("select UnitType from UnitType where UnitType LIKE '%{0}%' ", prefixText)
'
cmd.Parameters.AddWithValue("@ProductName", prefixText)
cmd.Connection = con
con.Open()
Dim UnitType As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
UnitType.Add(sdr("UnitType").ToString)
End While
con.Close()
Return UnitType
End Function
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"></asp:ScriptManager>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" CompletionInterval="100" EnableCaching="False" MinimumPrefixLength="1" ServiceMethod="SearchUnit" TargetControlID="TextBox4"></ajaxToolkit:AutoCompleteExtender>
</div>
No comments:
Post a Comment