ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Sum of DataTable columns total using Lambda Expression in Entity FrameWork in ASP.Net<blockquote><cite>fareed.fd7 says:</cite> <pre>decimal total = dt.AsEnumerable().Sum(row =&gt; row.Field&lt;decimal&gt;("TotalAmount"));</pre> </blockquote> <p>&nbsp;First make sure that TotalAmount field should be decimal in the datatable. If this is string then change with the below code.</p> <pre class="brush: csharp">decimal d = 0; decimal total = dt.AsEnumerable().Where(row =&gt; decimal.TryParse(row[&#34;TotalAmount&#34;].ToString(), out d)).Sum(row =&gt; d &gt; 0 ? d : 0);</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/Mon, 19 Dec 2016 05:35:04 GMTSum of DataTable columns total using Lambda Expression in Entity FrameWork in ASP.Net<p>sir is it possible to give text and the value in same gridview cell</p> <p>example: TotalAmount:&lt;total amount&gt;</p>http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/Mon, 19 Dec 2016 21:58:43 GMTSum of DataTable columns total using Lambda Expression in Entity FrameWork in ASP.Net<p>Yes you can. For that you have to take template field something like below.</p> <pre class="brush: html">&lt;asp:TemplateField&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;lblText&#34; Text=&#39;&lt;%# Eval(&#34;Text&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;asp:Label ID=&#34;lblValue&#34; Text=&#39;&lt;%# Eval(&#34;Value&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt;</pre> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/Tue, 20 Dec 2016 02:30:23 GMTSum of DataTable columns total using Lambda Expression in Entity FrameWork in ASP.Net<p>but we are displaying result using footerrow cells, how can i use templatefield there</p> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/Tue, 20 Dec 2016 02:35:59 GMTSum of DataTable columns total using Lambda Expression in Entity FrameWork in ASP.Net<p>Refer the below article.</p> <h1 class="header"><a title="Display sum of Columns total in GridView Footer in ASP.Net using C# and VB.Net'a" href="http://www.aspsnippets.com/Articles/Display-sum-of-Columns-total-in-GridView-Footer-in-ASPNet-using-C-and-VBNet.aspx">Display sum of Columns total in GridView Footer in ASP.Net using C# and VB.Net</a></h1>http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/http://www.aspforums.net/Threads/861050/Sum-of-DataTable-columns-total-using-Lambda-Expression-in-Entity-FrameWork-in-ASPNet/Tue, 20 Dec 2016 02:44:25 GMT