Hi ramco1917,
Please refer below sample.
HTML
<table class='table table-bordered datatable-fixed-left datatable-button-html5-basic' id='tbldata' style="margin-bottom: 0px !important;">
<thead>
<tr>
<th style="width: 20%;">Sr No.</th>
<th style="width: 20%;">Name</th>
<th style="width: 20%;">Delivered</th>
<th style="width: 20%;">Returned</th>
<th style="width: 20%;">Balance</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptData" runat="server">
<ItemTemplate>
<tr>
<td style="width: 20%;">
<asp:Literal ID="ltrlNum" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>" runat="server"></asp:Literal>
</td>
<td style="width: 20%;">
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'> </asp:Label></td>
<td style="width: 20%;">
<asp:Label ID="lblDelivered" runat="server" Text='<%# Eval("Delivered") %>'> </asp:Label></td>
<td style="width: 20%;">
<asp:Label ID="lblReturned" runat="server" Text='<%# Eval("Returned") %>'> </asp:Label></td>
<td style="width: 20%;">
<asp:Label ID="lblBalance" runat="server" Text='<%# Convert.ToDecimal(Eval("Delivered"))- Convert.ToDecimal(Eval("Returned"))%>'></asp:Label></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</tbody>
</table>
<table class='table table-bordered datatable-fixed-left datatable-button-html5-basic'>
<tr>
<td colspan="2" style="width: 40%;">Total</td>
<td style="width: 20%;">
<asp:Label ID="lblDeliveredTotal" runat="server" /></td>
<td style="width: 20%;">
<asp:Label ID="lblReturnedTotal" runat="server" /></td>
<td style="width: 20%;">
<asp:Label ID="lblBalanceTotal" runat="server" /></td>
</tr>
</table>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindRepeater();
}
}
private void BindRepeater()
{
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("Delivered");
dt.Columns.Add("Returned");
dt.Rows.Add("Mango", "10", "5");
dt.Rows.Add("Orange", "5", "2");
rptData.DataSource = dt;
rptData.DataBind();
decimal toDelivered = 0;
decimal toReturned = 0;
foreach (RepeaterItem item in rptData.Items)
{
toDelivered += Convert.ToDecimal((item.FindControl("lblDelivered") as Label).Text);
toReturned += Convert.ToDecimal((item.FindControl("lblReturned") as Label).Text);
}
lblDeliveredTotal.Text = toDelivered.ToString();
lblReturnedTotal.Text = toReturned.ToString();
lblBalanceTotal.Text = (toDelivered - toReturned).ToString();
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Me.BindRepeater()
End If
End Sub
Private Sub BindRepeater()
Dim dt As DataTable = New DataTable()
dt.Columns.Add("Name")
dt.Columns.Add("Delivered")
dt.Columns.Add("Returned")
dt.Rows.Add("Mango", "10", "5")
dt.Rows.Add("Orange", "5", "2")
rptData.DataSource = dt
rptData.DataBind()
Dim toDelivered As Decimal = 0
Dim toReturned As Decimal = 0
For Each item As RepeaterItem In rptData.Items
toDelivered += Convert.ToDecimal((TryCast(item.FindControl("lblDelivered"), Label)).Text)
toReturned += Convert.ToDecimal((TryCast(item.FindControl("lblReturned"), Label)).Text)
Next
lblDeliveredTotal.Text = toDelivered.ToString()
lblReturnedTotal.Text = toReturned.ToString()
lblBalanceTotal.Text = (toDelivered - toReturned).ToString()
End Sub
Screenshot