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.Pass (Send) multiple parameters to JavaScript function on jQuery DataTable row click in ASP.Net<p>Hi&nbsp;jovceka,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p>Once you get the response in the success function pass that response object to DataTable render function and using the property pass as additional parameter to any function.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;link rel=&#34;stylesheet&#34; href=&#34;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://code.jquery.com/jquery-1.11.1.min.js&#34;&gt;&lt;/script&gt; &lt;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;https://cdn.datatables.net/1.10.7/css/jquery.dataTables.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(document).ready(function () { $.ajax({ url: &#39;&lt;%= Page.ResolveUrl(&#34;~/WebService.asmx/GetFiles&#34;)%&gt;&#39;, method: &#39;post&#39;, dataType: &#39;json&#39;, success: function (data) { $(&#39;#datatable&#39;).dataTable({ paging: true, sort: true, pageLength: 3, searching: true, data: data, columns: [ { &#39;data&#39;: &#39;Id&#39; }, { &#39;data&#39;: &#39;Name&#39; }, { &#39;data&#39;: &#39;Id&#39;, &#39;sortable&#39;: false, &#39;searchable&#39;: false, &#39;render&#39;: function (index, row, data) { var Id = data.Id; var Str_Status = data.Status; if (Str_Status == &#39;1&#39;) { return &#39;&lt;label class=switch&gt;&lt;input type=checkbox onclick=chk_status(this,&#39; + Str_Status + &#39;,&#39; + Id + &#39;) data-id=&#39; + Id + &#39; id=chk_sts_str checked=checked &gt;&lt;span class=slider round&gt;&lt;/span&gt;&lt;/label&gt;&#39; } else { return &#39;&lt;label class=switch&gt;&lt;input type=checkbox onclick=chk_status(this,&#39; + Str_Status + &#39;,&#39; + Id + &#39;) data-id=&#39; + Id + &#39; id=chk_sts_str&gt;&lt;span class=slider round&gt;&lt;/span&gt;&lt;/label&gt;&#39; } } }] }); }, error: function (response) { alert(response.responseText); } }); }); function chk_status(chk, status, id) { var Status = &#34;&#34;; var isChecked = $(chk).is(&#34;:checked&#34;); if (isChecked) { Status = &#34;1&#34;; } else { Status = &#34;0&#34;; } alert(&#34;Status : &#34; + Status + &#34;\nId : &#34; + id + &#34;\nPrevious Status : &#34; + status); } &lt;/script&gt; &lt;div&gt; &lt;div style=&#34;width: 100%; border: 1px solid black; padding: 3px&#34;&gt; &lt;table id=&#34;datatable&#34;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Select&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt;</pre> <p><strong><span style="text-decoration: underline;">WebService</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System; using System.Web.Script.Serialization; using System.Web.Services; /// &lt;summary&gt; /// Summary description for WebService /// &lt;/summary&gt; [WebService(Namespace = "http://tempuri.org/")] [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 class File { public int Id { get; set; } public string Name { get; set; } public int Status { get; set; } } [WebMethod] public void GetFiles() { List&lt;File&gt; files = new List&lt;File&gt;(); files.Add(new File { Id = 1, Name = "Chrysanthemum.jpg", Status = 1 }); files.Add(new File { Id = 2, Name = "Desert.jpg", Status = 0 }); files.Add(new File { Id = 6, Name = "Koala.jpg", Status = 1 }); JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(files)); } } </pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Web Imports System.Web.Services Imports System.Web.Script.Serialization Imports System.Web.Services.Protocols ' 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:="http://tempuri.org/")&gt; _ &lt;WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _ &lt;Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()&gt; _ Public Class WebService Inherits System.Web.Services.WebService Public Class File Public Property Id As Integer Public Property Name As String Public Property Status As Integer End Class &lt;WebMethod()&gt; _ Public Sub GetFiles() Dim files As List(Of File) = New List(Of File)() files.Add(New File With {.Id = 1, .Name = "Chrysanthemum.jpg", .Status = 1}) files.Add(New File With {.Id = 2, .Name = "Desert.jpg", .Status = 0}) files.Add(New File With {.Id = 6, .Name = "Koala.jpg", .Status = 1}) Dim js As JavaScriptSerializer = New JavaScriptSerializer() Context.Response.Write(js.Serialize(files)) End Sub End Class</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/n3q8MNA.gif" alt="" width="302" height="230" /></p>https://www.aspforums.net:443/Threads/114685/Pass-Send-multiple-parameters-to-JavaScript-function-on-jQuery-DataTable-row-click-in-ASPNet/https://www.aspforums.net:443/Threads/114685/Pass-Send-multiple-parameters-to-JavaScript-function-on-jQuery-DataTable-row-click-in-ASPNet/Wed, 10 Jul 2019 03:40:05 GMT