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 HTML Table with CheckBox Check Uncheck based on Database column using jQuery AJAX<p>Hi&nbsp;jovceka,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;table id=&#34;example&#34;&gt; &lt;tr&gt; &lt;th&gt;ProductName&lt;/th&gt; &lt;th&gt;Proddetails&lt;/th&gt; &lt;th&gt;Status&lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://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 () { GetProduct(); }); function GetProduct() { $.ajax({ type: &#34;POST&#34;, contentType: &#34;application/json; charset=utf-8&#34;, url: &#34;WebService.asmx/Products&#34;, data: {}, dataType: &#34;json&#34;, success: function (data) { var table = $(&#39;#example&#39;); var rows = &#34;&#34;; for (var i = 0; i &lt; data.d.length; i++) { var name = data.d[i].ProductName; var details = data.d[i].Proddetails; var status = data.d[i].Status; rows += &#34;&lt;tr&gt;&lt;td&gt;&#34; + name + &#34;&lt;/td&gt;&lt;td&gt;&#34; + details + &#34;&lt;/td&gt;&#34;; if (status == &#34;true&#34;) { rows += &#34;&lt;td&gt;&lt;input type=checkbox id=chk1 checked=checked &gt;&lt;/td&gt;&lt;/tr&gt;&#34;; } else { rows += &#34;&lt;td&gt;&lt;input type=checkbox id=chk1 &gt;&lt;/td&gt;&lt;/tr&gt;&#34;; } } table.append(rows); }, error: function (response) { alert(&#34;Error while Showing update data&#34;); } }); } &lt;/script&gt;</pre> <p><strong><span style="text-decoration: underline;">C#</span></strong></p> <pre class="brush: csharp">using System.Collections.Generic; using System.Web.Services; /// &lt;summary&gt; /// Summary description for WebService /// &lt;/summary&gt; [WebService(Namespace = &#34;http://tempuri.org/&#34;)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class WebService : System.Web.Services.WebService { public WebService() { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public List&lt;Product&gt; Products() { List&lt;Product&gt; productList = new List&lt;Product&gt;(); productList.Add(new Product { ProductName = &#34;Chai&#34;, Proddetails = &#34;Soft drinks, coffees, teas, beers, and ales&#34;, Status = &#34;true&#34; }); productList.Add(new Product { ProductName = &#34;Aniseed Syrup&#34;, Proddetails = &#34;Sweet and savory sauces, relishes, spreads, and seasonings&#34;, Status = &#34;false&#34; }); productList.Add(new Product { ProductName = &#34;Manjimup Dried Apples&#34;, Proddetails = &#34;Dried fruit and bean curd&#34;, Status = &#34;false&#34; }); productList.Add(new Product { ProductName = &#34;Carnarvon Tigers&#34;, Proddetails = &#34;Seaweed and fish&#34;, Status = &#34;true&#34; }); return productList; } public class Product { public string ProductName { get; set; } public string Proddetails { get; set; } public string Status { get; set; } } } </pre> <p><strong><span style="text-decoration: underline;">VB.Net</span></strong></p> <pre class="brush: vb">Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols &#39; To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. &lt;System.Web.Script.Services.ScriptService()&gt; _ &lt;WebService(Namespace:=&#34;http://tempuri.org/&#34;)&gt; _ &lt;WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _ &lt;Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()&gt; _ Public Class WebServiceVB Inherits System.Web.Services.WebService &lt;WebMethod()&gt; Public Function Products() As List(Of Product) Dim productList As List(Of Product) = New List(Of Product)() productList.Add(New Product With { .ProductName = &#34;Chai&#34;, .Proddetails = &#34;Soft drinks, coffees, teas, beers, and ales&#34;, .Status = &#34;true&#34; }) productList.Add(New Product With { .ProductName = &#34;Aniseed Syrup&#34;, .Proddetails = &#34;Sweet and savory sauces, relishes, spreads, and seasonings&#34;, .Status = &#34;false&#34; }) productList.Add(New Product With { .ProductName = &#34;Manjimup Dried Apples&#34;, .Proddetails = &#34;Dried fruit and bean curd&#34;, .Status = &#34;false&#34; }) productList.Add(New Product With { .ProductName = &#34;Carnarvon Tigers&#34;, .Proddetails = &#34;Seaweed and fish&#34;, .Status = &#34;true&#34; }) Return productList End Function Public Class Product Public Property ProductName As String Public Property Proddetails As String Public Property Status As String End Class End Class</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/PmQIJ4L.jpg" alt="" width="472" height="191" /></span></strong></p>https://www.aspforums.net:443/Threads/215398/Populate-HTML-Table-with-CheckBox-Check-Uncheck-based-on-Database-column-using-jQuery-AJAX/https://www.aspforums.net:443/Threads/215398/Populate-HTML-Table-with-CheckBox-Check-Uncheck-based-on-Database-column-using-jQuery-AJAX/Fri, 30 Nov 2018 00:36:54 GMT