J
Jakob Lithner
I have a usercontrol where I intend to list all responsibilities a person has
for the coming weeks. In the section I will write the day, date and month. In
the row I will write a description of the responsibility.
<asp:Repeater ID="repResponsibility" runat="server">
<ItemTemplate>
<div class="adSection"><asp:Literal id="litSection"
runat="server"></asp:Literal></div>
<div class="adRow"><asp:Literal id="litRow"
runat="server"></asp:Literal></div>
</ItemTemplate>
</asp:Repeater>
Section and Row are formatted with an appropriate CSS-class.
To the Repeater I connect a collection and pick the values:
Protected Sub repResponsibility_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
repResponsibility.ItemDataBound
Dim r As Responsibility
Dim litSection As Literal
Dim litRow As Literal
Select Case e.Item.ItemType
Case ListItemType.Item
r = CType(e.Item.DataItem, Responsibility)
'Point out controls
litSection = CType(e.Item.FindControl("litSection"), Literal)
litRow = CType(e.Item.FindControl("litRow"), Literal)
'Set values
litSection.Text = r.ActivityStart.Value.ToString("dddd d
MMMM kl.HH")
litRow.Text = String.Format("{0}, {1}", r.Person,
r.ResponsibilityTypeName)
End Select
End Sub
All works fine. But it would be much nicer if I could group all
responsibilities that belongs to the same date under ONE section heading.
Do I really need to have two collections and two nested repeaters to
accomplish this, or is there a better alternative?
for the coming weeks. In the section I will write the day, date and month. In
the row I will write a description of the responsibility.
<asp:Repeater ID="repResponsibility" runat="server">
<ItemTemplate>
<div class="adSection"><asp:Literal id="litSection"
runat="server"></asp:Literal></div>
<div class="adRow"><asp:Literal id="litRow"
runat="server"></asp:Literal></div>
</ItemTemplate>
</asp:Repeater>
Section and Row are formatted with an appropriate CSS-class.
To the Repeater I connect a collection and pick the values:
Protected Sub repResponsibility_ItemDataBound(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
repResponsibility.ItemDataBound
Dim r As Responsibility
Dim litSection As Literal
Dim litRow As Literal
Select Case e.Item.ItemType
Case ListItemType.Item
r = CType(e.Item.DataItem, Responsibility)
'Point out controls
litSection = CType(e.Item.FindControl("litSection"), Literal)
litRow = CType(e.Item.FindControl("litRow"), Literal)
'Set values
litSection.Text = r.ActivityStart.Value.ToString("dddd d
MMMM kl.HH")
litRow.Text = String.Format("{0}, {1}", r.Person,
r.ResponsibilityTypeName)
End Select
End Sub
All works fine. But it would be much nicer if I could group all
responsibilities that belongs to the same date under ONE section heading.
Do I really need to have two collections and two nested repeaters to
accomplish this, or is there a better alternative?