Here's another example that can be done by .aspx.cs (CodeBehind)
using System.IO;
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Cliente> lstCliente = new List<Cliente>
{
new Cliente{ Id = 1, Nome = "Cliente1"},
new Cliente{ Id = 2, Nome = "Cliente2"},
new Cliente{ Id = 3, Nome = "Cliente3"},
new Cliente{ Id = 4, Nome = "Cliente4"},
};
StringWriter stringWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Ul); //Cria a tag ul
foreach (Cliente cliente in lstCliente)
{
htmlWriter.RenderBeginTag(HtmlTextWriterTag.Li); //Cria tag li
htmlWriter.Write(string.Concat(cliente.Id, ": ", cliente.Nome));
htmlWriter.RenderEndTag(); //Fecha tag li
}
htmlWriter.RenderEndTag(); Fecha tag ul
ltListaClientes.Text = stringWriter.ToString();
}
}
.aspx I added a literal to receive the list
<asp:Literal id="ltListaClientes" runat="server" />