Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Ajax Autocompete Trim output on selection

$
0
0

Hello Everybody,

i need some help in my code below, want to select only dt.Rows(i)(1).ToString() in the textbox after display the autocomplete menu

all is working fine but i need a way on javascript or asp to trim productid spilt by "|" on item selection

asp.net code:

<System.Web.Script.Services.ScriptMethod()> _
<System.Web.Services.WebMethod()> _
Public Shared Function productidautocomplete(ByVal prefixText As String) As List(Of String)
Dim dal As New dal
Dim dt As New DataTable()
Dim con As New SqlConnection("data source = ng ; initial catalog= ng ; uid=sa ; pwd=123456 ")
con.Open()
Dim cmd As New SqlCommand("select * from ProductsT where ProductID Like @Name+'%'", con)
Dim da As New SqlDataAdapter(cmd)
cmd.Parameters.AddWithValue("@Name", prefixText)
da.Fill(dt)
Dim productid As New List(Of String)()
For i As Integer = 0 To dt.Rows.Count - 1
productid.Add(dt.Rows(i)(2).ToString() + " | " + dt.Rows(i)(1).ToString())
Next
Return productid

End Function

Ajax code:

<ajax:ToolkitScriptManager ID="ScriptManager1" runat="server"/>

<asp:TextBox ID="txtcustomerid" runat="server" Height="25px" Width="440px"
style= "text-align: right"></asp:TextBox>
<ajax:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtcustomerid"
MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="1000" ServiceMethod="customeridautocomplete" >

</ajax:AutoCompleteExtender>


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>