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.Calculate Sum (Total) of Checked ASP.Net GridView Rows using jQuery<p>Hi <a class="username" rel="VinitaAkha"> VinitaAkha</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&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*=chk]&#39;).on(&#39;change&#39;, function () { var value = 0; $(&#39;[id*=chk]:checked&#39;).each(function () { var row = $(this).closest(&#39;tr&#39;); value = value + parseInt(row.find(&#39;[id*=lblValue]&#39;).html()); }); $(&#34;[id*=gvData] [id*=lblGrandTotal]&#34;).html(value); }); }); &lt;/script&gt; &lt;asp:GridView ID=&#34;gvData&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34; ShowFooter=&#34;true&#34;&gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText=&#34;Select&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:CheckBox ID=&#34;chk&#34; runat=&#34;server&#34; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText=&#34;Values&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;lblItems&#34; runat=&#34;server&#34; Text=&#39;&lt;%# Eval(&#34;Items&#34;) %&gt;&#39;&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText=&#34;Values&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;lblValue&#34; runat=&#34;server&#34; Text=&#39;&lt;%# Eval(&#34;Price&#34;) %&gt;&#39;&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;FooterTemplate&gt; Total : &lt;asp:Label ID=&#34;lblGrandTotal&#34; runat=&#34;server&#34; /&gt; &lt;/FooterTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data; </pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn(&#34;Items&#34;, typeof(string)), new DataColumn(&#34;Price&#34;, typeof(int)) }); dt.Rows.Add(&#34;opisometer.&#34;, 10); dt.Rows.Add(&#34;dividers&#34;, 20); dt.Rows.Add(&#34;protractor&#34;, 30); dt.Rows.Add(&#34;compass&#34;, 40); dt.Rows.Add(&#34;ellipsograph&#34;, 60); gvData.DataSource = dt; gvData.DataBind(); } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)Handle Me.Load If Not Me.IsPostBack Then Dim dt As DataTable = New DataTable() dt.Columns.AddRange(New DataColumn() {New DataColumn(&#34;Items&#34;, GetType(String)), New DataColumn(&#34;Price&#34;, GetType(Integer))}) dt.Rows.Add(&#34;opisometer.&#34;, 10) dt.Rows.Add(&#34;dividers&#34;, 20) dt.Rows.Add(&#34;protractor&#34;, 30) dt.Rows.Add(&#34;compass&#34;, 40) dt.Rows.Add(&#34;ellipsograph&#34;, 60) gvData.DataSource = dt gvData.DataBind() End If End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/aGaoWeN.gif" alt="" width="246" height="360" /></p>https://www.aspforums.net:443/Threads/179064/Calculate-Sum-Total-of-Checked-ASPNet-GridView-Rows-using-jQuery/https://www.aspforums.net:443/Threads/179064/Calculate-Sum-Total-of-Checked-ASPNet-GridView-Rows-using-jQuery/Wed, 31 Jul 2019 01:45:55 GMT