Hi ramco1917,
Please refer below sample.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
<asp:Label ID="lblHtml" runat="server" />
<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>
Namespace
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'>Budget Amount</th</tr></thead>");
htmlTable.Append("<tbody>");
foreach (var colum in Result)
{
rownum++;
htmlTable.Append("<tr>");
htmlTable.Append("<td class='ID'>" + rownum + " <span style='display:none'>" + colum.CustomerID + "</span></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("</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></tr></tfoot>");
htmlTable.Append("</table>");
lblHtml.Text = htmlTable.ToString();
}
}
}
catch (Exception ex)
{
}
}
VB.Net
Protected Sub Page_Load(sender As Object, 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 Integer = 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'>Budget Amount</th</tr></thead>")
htmlTable.Append("<tbody>")
For Each colum In Result
rownum += 1
htmlTable.Append("<tr>")
htmlTable.Append("<td class='ID'>" & rownum & " <span style='display:none'>" + colum.CustomerID & "</span></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("</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></tr></tfoot>")
htmlTable.Append("</table>")
lblHtml.Text = htmlTable.ToString()
End If
End Using
Catch ex As Exception
End Try
End Sub
Screenshot