I am retrieving & displaying records from a SQL Server DB table in a Repeater. Now I want to display the sum of all the rows of 2 columns in the FooterTemplate of the Repeater. This is what I have done:
<script language="VB" runat="server">
Sub Page_Load(obj As Object,ea As EventArgs)
Dim iBasicTotal As Double=0
Dim iPFTotal As Double=0
objDapter=New SQLDataAdapter("SELECT blah...blah..",objConn)
objDS=new DataSet()
objDapter.Fill(objDS,"PFRegister"
dTable=objDS.Tables("PFRegister"
For Each dRow In dTable.Rows
iBasicTotal=iBasicTotal+CType(dRow("Basic",Double)
iPFTotal=iPFTotal+CType(dRow("PF",Double)
Next
myRep.DataSource=objDS.Tables("PFRegister".DefaultView
myRep.DataBind()
End Sub
</script>
............
<asp:Repeater id="myRep" OnItemDataBound="AttachFooter" runat="server">
<HeaderTemplate>
<table border=2>
<!-- Display The Column Headers Here -->
</HeaderTemplate>
<ItemTemplate>
<!-- Display The Records Here -->
</ItemTemplate>
<FooterTemplate>
<tr>
<th colspan=3>TOTAL</th>
<td><asp:Label id="BasicTotal" runat="server"/>
<td><asp:Label id="PFTotal" runat="server"/>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Now my question is how do I pass the 2 totals (iBasicTotal & iPFTotal) from the Page_Load Sub to the Sub AttachFooter (OnItemDataBound event) so that using the ListItemType property in the AttachFooter Sub, I can display the 2 totals in the 2 labels in the FooterTemplate i.e. the AttachFooter Sub will look something like this:
Sub AttachFooter(obj As Object,ea As RepeaterItemEventArgs)
If(ea.Item.ItemType=ListItemType.Footer) Then
CType(ea.Item.FindControl("basicLabel",Label).Text=BasicTotal
CType(ea.Item.FindControl("pfLabel",Label).Text=PFTotal
End If
End Sub
So how do I pass the values of the 2 variables in the Page_Load Sub, iBasicTotal & iPFTotal, to the AttachFooter Sub?
Thanks,
Arpan
<script language="VB" runat="server">
Sub Page_Load(obj As Object,ea As EventArgs)
Dim iBasicTotal As Double=0
Dim iPFTotal As Double=0
objDapter=New SQLDataAdapter("SELECT blah...blah..",objConn)
objDS=new DataSet()
objDapter.Fill(objDS,"PFRegister"
dTable=objDS.Tables("PFRegister"
For Each dRow In dTable.Rows
iBasicTotal=iBasicTotal+CType(dRow("Basic",Double)
iPFTotal=iPFTotal+CType(dRow("PF",Double)
Next
myRep.DataSource=objDS.Tables("PFRegister".DefaultView
myRep.DataBind()
End Sub
</script>
............
<asp:Repeater id="myRep" OnItemDataBound="AttachFooter" runat="server">
<HeaderTemplate>
<table border=2>
<!-- Display The Column Headers Here -->
</HeaderTemplate>
<ItemTemplate>
<!-- Display The Records Here -->
</ItemTemplate>
<FooterTemplate>
<tr>
<th colspan=3>TOTAL</th>
<td><asp:Label id="BasicTotal" runat="server"/>
<td><asp:Label id="PFTotal" runat="server"/>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Now my question is how do I pass the 2 totals (iBasicTotal & iPFTotal) from the Page_Load Sub to the Sub AttachFooter (OnItemDataBound event) so that using the ListItemType property in the AttachFooter Sub, I can display the 2 totals in the 2 labels in the FooterTemplate i.e. the AttachFooter Sub will look something like this:
Sub AttachFooter(obj As Object,ea As RepeaterItemEventArgs)
If(ea.Item.ItemType=ListItemType.Footer) Then
CType(ea.Item.FindControl("basicLabel",Label).Text=BasicTotal
CType(ea.Item.FindControl("pfLabel",Label).Text=PFTotal
End If
End Sub
So how do I pass the values of the 2 variables in the Page_Load Sub, iBasicTotal & iPFTotal, to the AttachFooter Sub?
Thanks,
Arpan