Hi ramco1917,
Please refer below sample.
HTML
<div class="container" style="padding-top:10px;">
<asp:Label ID="lblHtml" runat="server" />
</div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" />
<script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var trs = $("#tbldata tbody").find("tr");
var sum = 0;
$(trs).each(function () {
var tds = $(this).find('td');
sum = sum + parseFloat($(tds).eq(2).html());
});
$("#lblSum").html(sum);
});
</script>
Namespaces
C#
using System.Text;
VB.Net
Imports System.Text
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.GetData();
}
}
private void GetData()
{
try
{
using (NORTHWINDEntities entities = new NORTHWINDEntities())
{
StringBuilder htmlTable = new StringBuilder();
Int32 rownum = 0;
var Result = (from customer in entities.Orders.Take(5)
select customer).ToList();
if (Result != null)
{
htmlTable.Append("<table class='table table-striped table-hover dataTable table-bordered' data-provide='data-table' id='tbldata'>");
htmlTable.Append("<thead><tr><th>ID</th><th>Year</th><th style='text-align:right'>Amount</th</tr><th></th></thead>");
htmlTable.Append("<tbody>");
foreach (var colum in Result)
{
rownum++;
htmlTable.Append("<tr>");
htmlTable.Append("<td>" + colum.CustomerID + "</td>");
htmlTable.Append("<td>" + colum.OrderDate.Value.Year + "</td>");
htmlTable.Append("<td style='text-align:right'>" + Convert.ToDecimal(colum.Freight).ToString("0,0", System.Globalization.CultureInfo.CreateSpecificCulture("hi-IN")) + "</td>");
htmlTable.Append("<td class='text-center'><a id='btnEdit' style='cursor:pointer;' class='list-icons-item text-primary-600' title='Edit' href='NewTraining.aspx?val=" + colum.CustomerID + "'><i class='fas fa-pencil-alt mr-1'></i> </a>" + "</td>");
htmlTable.Append("</tr>");
}
htmlTable.Append("</tbody>");
htmlTable.Append("<tfoot><tr><td colspan='2' style='text-align:center'>Total</td><td style='text-align:right' id='lblSum'></td><td></td></tr></tfoot>");
htmlTable.Append("</table>");
lblHtml.Text = htmlTable.ToString();
}
}
}
catch (Exception ex)
{
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.GetData()
End If
End Sub
Private Sub GetData()
Try
Using entities As NORTHWINDEntities = New NORTHWINDEntities()
Dim htmlTable As StringBuilder = New StringBuilder()
Dim rownum As Int32 = 0
Dim Result = (From customer In entities.Orders.Take(5) Select customer).ToList()
If Result IsNot Nothing Then
htmlTable.Append("<table class='table table-striped table-hover dataTable table-bordered' data-provide='data-table' id='tbldata'>")
htmlTable.Append("<thead><tr><th>ID</th><th>Year</th><th style='text-align:right'>Amount</th</tr><th></th></thead>")
htmlTable.Append("<tbody>")
For Each colum In Result
rownum += 1
htmlTable.Append("<tr>")
htmlTable.Append("<td>" & colum.CustomerID & "</td>")
htmlTable.Append("<td>" & colum.OrderDate.Value.Year & "</td>")
htmlTable.Append("<td style='text-align:right'>" & Convert.ToDecimal(colum.Freight).ToString("0,0", System.Globalization.CultureInfo.CreateSpecificCulture("hi-IN")) & "</td>")
htmlTable.Append("<td class='text-center'><a id='btnEdit' style='cursor:pointer;' class='list-icons-item text-primary-600' title='Edit' href='NewTraining.aspx?val=" & colum.CustomerID & "'><i class='fas fa-pencil-alt mr-1'></i> </a>" & "</td>")
htmlTable.Append("</tr>")
Next
htmlTable.Append("</tbody>")
htmlTable.Append("<tfoot><tr><td colspan='2' style='text-align:center'>Total</td><td style='text-align:right' id='lblSum'></td><td></td></tr></tfoot>")
htmlTable.Append("</table>")
lblHtml.Text = htmlTable.ToString()
End If
End Using
Catch ex As Exception
End Try
End Sub
Screenshot