Custom Control (Repeater Control):
Create a custom control inherited from Repeater control rather than inherited from Control/WebControl class as approach 4, and then modify the retrieved data as surrounded by a pair of <li> and </li> in the ItemDataBound event.
E.g. (Source: Juliet's blog)
public void InstantiateIn(Control container) {
LiteralControl l;
switch(templateType) {
case ListItemType.Header:
l = new LiteralControl();
l.Text = "<ul";
if(CssClass != null && CssClass.Length > 0)
l.Text += " class=\"" + CssClass + "\"";
l.Text += ">";
container.Controls.Add(l);
break;
case ListItemType.Item:
case ListItemType.AlternatingItem:
l = new LiteralControl();
l.DataBinding += new EventHandler(Item_DataBinding);
container.Controls.Add(l);
break;
case ListItemType.Footer:
l = new LiteralControl();
l.Text = "</ul>";
container.Controls.Add(l);
break;
}
}
public void Item_DataBinding(object sender, EventArgs e) {
LiteralControl l = (LiteralControl) sender;
RepeaterItem container = (RepeaterItem) l.NamingContainer;
l.Text = "<li>" + (string)(container.DataItem) + "</li>";
}