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.Populate DropDownList from JSON Array using jQuery AJAX in ASP.Net<p>Hi&nbsp;v@run,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Database</span></strong></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } public string GetJsonData() { NorthwindEntities entities = new NorthwindEntities(); var products = entities.Products.Take(10).ToList(); System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); return serializer.Serialize(products); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;script type=&#34;text/javascript&#34; src=&#34;https://code.jquery.com/jquery-2.2.3.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; function get_sbu() { $.ajax({ type: &#34;POST&#34;, url: &#34;Home/GetJsonData&#34;, data: &#39;{}&#39;, contentType: &#34;application/json; charset=utf-8&#34;, dataType: &#34;json&#34;, success: function (response) { var products = response; $.each(products, function () { $(&#34;[id*=ddlProducts]&#34;) .append(&#39;&lt;option value = &#34;&#39; + this.ProductID + &#39; | &#39; + this.SupplierID + &#39; | &#39; + this.CategoryID + &#39; | &#39; + this.UnitPrice + &#39;&#34;&gt;&#39; + this.ProductName + &#39;(&#39; + this.ProductID + &#39;)&lt;/option&gt;&#39;); }); }, failure: function (response) { }, error: function (response) { } }); } &lt;/script&gt; &lt;input type=&#34;button&#34; value=&#34;Bind DropDown&#34; onclick=&#34;get_sbu()&#34; /&gt; &lt;br /&gt; &lt;select id=&#34;ddlProducts&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshots</span></strong></p> <p><span style="text-decoration: underline;">The Form</span></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/1JUvEQ8.jpg" alt="" width="245" height="209" /></span></strong></p> <p><span style="text-decoration: underline;">Generated Text and Value</span></p> <p><img src="https://i.imgur.com/bEXqcin.jpg" alt="" width="472" height="199" /></p>https://www.aspforums.net:443/Threads/407002/Populate-DropDownList-from-JSON-Array-using-jQuery-AJAX-in-ASPNet/https://www.aspforums.net:443/Threads/407002/Populate-DropDownList-from-JSON-Array-using-jQuery-AJAX-in-ASPNet/Mon, 13 May 2019 07:18:51 GMT