Okay that worked, thanks. Now I need to add the second footer for the percentages. Now I already have the code to calculate the percentages, but how to do I add the additional footer.
Do I use the alternatignitemtemplate as the additional footer or do I use the separatortemplate as the additonal footer?
Let me know thanks.
aspx page:
Code:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table border=1>
<tr>
<td><b>Received</b></td>
<td><b>Answars</b></td>
<td><b>Product</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td> <%#DataBinder.Eval(Container.DataItem, "received")%> </td>
<td> <%#DataBinder.Eval(Container.DataItem, "ansers")%> </td>
<td> <%# DataBinder.Eval(Container.DataItem, "product") %> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td> <asp:Label ID="lblreceieved" runat="server" Text=""></asp:Label> </td>
<td> <asp:Label ID="lblansers" runat="server" Text=""></asp:Label> </td>
<td> <asp:Label ID="Label1" runat="server" Text="Total"></asp:Label> </td>
</tr>
</FooterTemplate>
<AlternatingItemTemplate>
</AlternatingItemTemplate>
<SeparatorTemplate>
</SeparatorTemplate>
</asp:Repeater>
aspx.vb page:
Code:
Protected Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
'Dim total2 As Decimal = 0
'If e.Item.DataItem = DataControlRowType.DataRow Then
' Total += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "received")))
' total2 += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "ansers")))
'ElseIf e.Item.DataItem = DataControlRowType.Footer Then
' e.Item.DataItem.cell(0).text = Total.ToString()
' e.Item.DataItem.cell(1).text = total2.ToString()
Dim total2 As Decimal = 0
'If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
' Total += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "received")))
' total2 += GetUnitPrice(Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "ansers")))
If e.Item.ItemType = ListItemType.Footer Then
Dim lblrec As Label = TryCast(e.Item.FindControl("lblreceieved"), Label)
lblrec.Text = Repeater1.Items.Count
Dim lblans As Label = TryCast(e.Item.FindControl("lblansers"), Label)
lblans.Text = Repeater1.Items.Count
'e.Item.DataItem.cell(0).text = Total.ToString()
'e.Item.DataItem.cell(1).text = total2.ToString()
End If
End Sub

Originally Posted by
jmurrayhead
You will want to check the row type like this in a repeater:
Code:
If e.Item.RowType = ListItemType.Item Or e.Item.RowType = ListItemType.AlternatingItem Then
....
ElseIf e.Item.RowType = ListItemType.Footer Then
....
End If
Bookmarks