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.Display Sum of dynamic generated TextBoxes in HTML Table Rows from Code Behind using jQuery<p>Hey <a class="username" rel="RumeValid">RumeValid</a>,</p> <p>Please 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.9.1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; $(function () { $(&#39;input[type=text]&#39;).on(&#39;keyup&#39;, function () { var trs = $(this).closest(&#39;tr&#39;); var tds = trs.find(&#39;td&#39;); var acco = $(tds).find(&#39;[id*=txtaccomod]&#39;).val() != &#34;&#34; ? $(tds).find(&#39;[id*=txtaccomod]&#39;).val() : &#34;0&#34;; var trans = $(tds).find(&#39;[id*=txttranspot]&#39;).val() != &#34;&#34; ? $(tds).find(&#39;[id*=txttranspot]&#39;).val() : &#34;0&#34;; var feeding = $(tds).find(&#39;[id*=txtfeeding]&#39;).val() != &#34;&#34; ? $(tds).find(&#39;[id*=txtfeeding]&#39;).val() : &#34;0&#34;; var ot = $(tds).find(&#39;[id*=txtothercst]&#39;).val() != &#34;&#34; ? $(tds).find(&#39;[id*=txtothercst]&#39;).val() : &#34;0&#34;; $(tds).find(&#39;[id*=txttotcst]&#39;).val(parseInt(acco) + parseInt(trans) + parseInt(feeding) + parseInt(ot)); }); }); &lt;/script&gt; &lt;div&gt; &lt;asp:Label ID=&#34;lblText&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt;</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) { string strTR = &#34;&lt;table&gt;&#34;; for (int i = 0; i &lt; 5; i++) { strTR = strTR + &#34;&lt;tr&gt;&#34; + &#34;&lt;td&gt; &#34; + &#34; &lt;span&gt;&#34; + (i + 1).ToString() + &#34;&lt;/span&gt; &#34; + &#34;&lt;/td&gt;&#34; + &#34;&lt;td&gt; &#34; + &#34; &lt;input name=&#39;txtaccomod&#39; type=&#39;text&#39; id=&#39;txtaccomod&#34; + (i + 1).ToString().Trim() + &#34;&#39; class=&#39;txtaccomod&#39; style=&#39;width:100px;&#39; /&gt; &#34; + &#34;&lt;/td&gt;&#34; + &#34;&lt;td&gt; &#34; + &#34; &lt;input name=&#39;txttranspot&#39; type=&#39;text&#39; id=&#39;txttranspot&#34; + (i + 1).ToString().Trim() + &#34;&#39; class=&#39;txttranspot&#39; style=&#39;width:100px;&#39; /&gt; &#34; + &#34;&lt;/td&gt;&#34; + &#34;&lt;td&gt; &#34; + &#34; &lt;input name=&#39;txtfeeding&#39; type=&#39;text&#39; id=&#39;txtfeeding&#34; + (i + 1).ToString().Trim() + &#34;&#39; class=&#39;txtfeeding&#39; style=&#39;width:100px;&#39; /&gt; &#34; + &#34;&lt;/td&gt;&#34; + &#34;&lt;td&gt; &#34; + &#34; &lt;input name=&#39;txtothercst&#39; type=&#39;text&#39; id=&#39;txtothercst&#34; + (i + 1).ToString().Trim() + &#34;&#39; class=&#39;txtothercst&#39; style=&#39;width:100px;&#39; /&gt; &#34; + &#34;&lt;/td&gt;&#34; + &#34;&lt;td&gt; &#34; + &#34; &lt;input name=&#39;txttotcst&#39; type=&#39;text&#39; id=&#39;txttotcst&#34; + (i + 1).ToString().Trim() + &#34;&#39; class=&#39;txttotcst&#39; style=&#39;width:100px;&#39; /&gt; &#34; + &#34;&lt;/td&gt;&#34; + &#34;&lt;/tr&gt;&#34;; } lblText.Text = strTR + &#34;&lt;/table&gt;&#34;; }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim strTR As String = &#34;&lt;table&gt;&#34; For i As Integer = 0 To 5 - 1 strTR = strTR &amp; &#34;&lt;tr&gt;&#34; &amp; &#34;&lt;td&gt; &#34; &amp; &#34; &lt;span&gt;&#34; &amp; (i + 1).ToString() &amp; &#34;&lt;/span&gt; &#34; &amp; &#34;&lt;/td&gt;&#34; &amp; &#34;&lt;td&gt; &#34; &amp; &#34; &lt;input name=&#39;txtaccomod&#39; type=&#39;text&#39; id=&#39;txtaccomod&#34; &amp; (i + 1).ToString().Trim() &amp; &#34;&#39; class=&#39;txtaccomod&#39; style=&#39;width:100px;&#39; /&gt; &#34; &amp; &#34;&lt;/td&gt;&#34; &amp; &#34;&lt;td&gt; &#34; &amp; &#34; &lt;input name=&#39;txttranspot&#39; type=&#39;text&#39; id=&#39;txttranspot&#34; &amp; (i + 1).ToString().Trim() &amp; &#34;&#39; class=&#39;txttranspot&#39; style=&#39;width:100px;&#39; /&gt; &#34; &amp; &#34;&lt;/td&gt;&#34; &amp; &#34;&lt;td&gt; &#34; &amp; &#34; &lt;input name=&#39;txtfeeding&#39; type=&#39;text&#39; id=&#39;txtfeeding&#34; &amp; (i + 1).ToString().Trim() &amp; &#34;&#39; class=&#39;txtfeeding&#39; style=&#39;width:100px;&#39; /&gt; &#34; &amp; &#34;&lt;/td&gt;&#34; &amp; &#34;&lt;td&gt; &#34; &amp; &#34; &lt;input name=&#39;txtothercst&#39; type=&#39;text&#39; id=&#39;txtothercst&#34; &amp; (i + 1).ToString().Trim() &amp; &#34;&#39; class=&#39;txtothercst&#39; style=&#39;width:100px;&#39; /&gt; &#34; &amp; &#34;&lt;/td&gt;&#34; &amp; &#34;&lt;td&gt; &#34; &amp; &#34; &lt;input name=&#39;txttotcst&#39; type=&#39;text&#39; id=&#39;txttotcst&#34; &amp; (i + 1).ToString().Trim() &amp; &#34;&#39; class=&#39;txttotcst&#39; style=&#39;width:100px;&#39; /&gt; &#34; &amp; &#34;&lt;/td&gt;&#34; &amp; &#34;&lt;/tr&gt;&#34; Next lblText.Text = strTR &amp; &#34;&lt;/table&gt;&#34; End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/iiFOT07.gif" alt="" width="472" height="202" /></p>https://www.aspforums.net:443/Threads/192922/Display-Sum-of-dynamic-generated-TextBoxes-in-HTML-Table-Rows-from-Code-Behind-using-jQuery/https://www.aspforums.net:443/Threads/192922/Display-Sum-of-dynamic-generated-TextBoxes-in-HTML-Table-Rows-from-Code-Behind-using-jQuery/Mon, 10 Dec 2018 06:19:34 GMT