ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.jQuery AutoComplete TextBox and Pass select item to another TextBox using jQuery Ajax in ASP.Net<p>Hi,</p> <p>By refering the below link i have created sample that full fill your requirement. So you need to modify the code as per your requirement. You need to bind the result as per the textbox value after clicking the table cell on client textchange event.</p> <h1 class="header"><a class="title f16" href="http://www.aspforums.net/Threads/160743/Filter-DataList-on-TextBox-KeyPress-using-jQuery-in-ASPNet/">Filter DataList on TextBox KeyPress using jQuery in ASP.Net</a></h1> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head id=&#34;Head1&#34; runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;style type=&#34;text/css&#34;&gt; body { font-family: Arial; font-size: 10pt; } table { border: 1px solid #ccc; } table th { background-color: #F7F7F7; color: #333; font-weight: bold; } table th, table td { padding: 5px; border-color: #ccc; } &lt;/style&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $(&#39;[id*=txtSearch]&#39;).on(&#34;keyup&#34;, function () { $.ajax({ type: &#34;POST&#34;, url: &#34;CS.aspx/GetCustomers&#34;, data: &#39;{search:&#34;&#39; + $(this).val() + &#39;&#34;}&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: OnSuccess, failure: function (response) { alert(response.d); }, error: function (response) { alert(response.d); } }); }); }); function OnSuccess(response) { // Assign repeat column values var repeatColumn = 3; var table = &#34;&lt;table cellpadding=&#39;2&#39; cellspacing=&#39;0&#39; border=&#39;1&#39; Style=&#39;width: 70%; border: dashed 2px #04AFEF; background-color: #B0E2F5&#39;&gt;&#34;; if (response.d != &#39;&#39;) { var xmlDoc = $.parseXML(response.d); var xml = $(xmlDoc); var customers = xml.find(&#34;Customers&#34;); customers.each(function (i, item) { if ((i == 0) || (i % repeatColumn) == 0) { table += &#34;&lt;tr&gt;&#34;; } var customer = $(this); var contactName = customer.find(&#34;ContactName&#34;).text(); var customerID = customer.find(&#34;CustomerID&#34;).text(); var companyName = customer.find(&#34;CompanyName&#34;).text(); table += &#34;&lt;td&gt;&lt;b&gt;Contact Name:&lt;/b&gt;&lt;span id=&#39;lblContactName&#39; style=&#39;cursor:pointer;&#39; class=&#39;contactName&#39;&gt; &#34; + contactName + &#34;&lt;/span&gt;&lt;br/&gt;&#34; + &#34;&lt;b&gt;Customer ID:&lt;/b&gt;&#34; + customerID + &#34;&lt;br/&gt;&lt;b&gt;Company Name:&lt;/b&gt;&#34; + companyName table += &#34;&lt;/td&gt;&#34;; if ((i == customers.length - 1) || (((i + 1) % repeatColumn == 0)) || customers.length == 1) { table += &#34;&lt;/tr&gt;&#34;; } }); } else { table += &#34;&lt;tr align=&#39;center&#39;&gt;&lt;td&gt;&lt;b&gt;No Result For the Criteria&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&#34;; } table += &#34;&lt;/table&gt;&#34;; $(&#34;#dvCustomers&#34;).html(table); $(&#34;.contactName&#34;).click(function () { var contactname = $(this).html(); $(&#39;[id*=txtResultValue]&#39;).val(contactname); }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;br /&gt; Search value&lt;asp:TextBox runat=&#34;server&#34; ID=&#34;txtSearch&#34; /&gt; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Result Value&lt;asp:TextBox ID=&#34;txtResultValue&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;div id=&#34;dvCustomers&#34;&gt; &lt;/div&gt; &lt;br /&gt;&lt;br /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">public static DataSet GetCustomersData(string search) { string query = &#34;[GetCustomersPageWiseSearch]&#34;; SqlCommand cmd = new SqlCommand(query); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue(&#34;@PageIndex&#34;, 1); cmd.Parameters.AddWithValue(&#34;@PageSize&#34;, 100); cmd.Parameters.AddWithValue(&#34;@search&#34;, search); cmd.Parameters.Add(&#34;@RecordCount&#34;, SqlDbType.Int, 4).Direction = ParameterDirection.Output; return GetData(cmd); } private static DataSet GetData(SqlCommand cmd) { string strConnString = ConfigurationManager.ConnectionStrings[&#34;constr&#34;].ConnectionString; using (SqlConnection con = new SqlConnection(strConnString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataSet ds = new DataSet()) { sda.Fill(ds, &#34;Customers&#34;); return ds; } } } } [System.Web.Services.WebMethod] public static string GetCustomers(string search) { DataSet ds = GetCustomersData(search); if (ds.Tables[0].Rows.Count &gt; 0) { return GetCustomersData(search).GetXml(); } else { return &#34;&#34;; } }</pre> <p><span style="text-decoration: underline;">Screenshot</span></p> <p><span style="text-decoration: underline;"><img src="https://i.imgur.com/jB1rsjO.gif" alt="" width="468" height="280" /></span></p>https://www.aspforums.net:443/Threads/147983/jQuery-AutoComplete-TextBox-and-Pass-select-item-to-another-TextBox-using-jQuery-Ajax-in-ASPNet/https://www.aspforums.net:443/Threads/147983/jQuery-AutoComplete-TextBox-and-Pass-select-item-to-another-TextBox-using-jQuery-Ajax-in-ASPNet/Fri, 05 May 2017 10:08:43 GMT