I have a contacts page, with many categories. Not all categories will have contacts in them, but all categories will be shown on the page (populated or empty).
I would like to create a repeater for each of the categories and fill it with an ItemTemplate. The repeater, item template and inner html i wish to create in the code behind file.
My issue is i don't know how to create a generic ItemTemplate with my own html, as everytime i set repeater.ItemTemplate i have to pick from a predefined like GridTemplate or ListItemTemplate etc.
existing code i have so far:
Public Sub BuildRepeater()
For Each itemType In types
Dim sb As New StringBuilder()
sb.Append("<div class=""contact-fieldset"">")
sb.Append("<h2><%# Eval(""FullName"") %></h2>")
sb.Append("<h4><%# Eval(""TypeName"") %></h4>")
sb.Append("<p><%# Eval(""Address"") %></p>")
sb.Append("<label style=""display:<%# IIF(Eval(""WorkPhone"") <> DBNull.Value.ToString(),""block"",""none"")%>""class=""contact-label"">Work Phone: </label>")
sb.Append("<p style=""display:<%# IIF(Eval(""WorkPhone"") <> DBNull.Value.ToString(),""block"",""none"")%>""><%# Eval(""WorkPhone"") %></p>")
sb.Append("<label style=""display:<%# IIF(Eval(""Mobile"") <> DBNull.Value.ToString(),""block"",""none"")%>"" class=""contact-label"">Mobile: </label>")
sb.Append("<p style=""display:<%# IIF(Eval(""Mobile"") <> DBNull.Value.ToString(),""block"",""none"")%>""><%# Eval(""Mobile"") %></p>")
sb.Append("<label class=""contact-label"">Email: </label>")
sb.Append("<a href=""mailto:<%# Eval(""Email"")%>""><%# Eval(""Email"")%></a>")
sb.Append("</div>")
sb.ToString()
Dim repeater As New Repeater()
repeater.DataSource = (From c In contacts _
Where c.TypeName = itemType.Name _
Select c).ToList()
repeater.DataBind()
repeater.ItemTemplate = [add code here to get sb.tostring]
contactList.Controls.Add(repeater)
Next
End Sub