ASP.NET how to display data without GridView
I am newbie in ASP.NET. I have prepared an arraylist of Product and want to display in the page. Easiest way is binding the arraylist to GridView.
But I don't have flexibility there, since it will automatically generate a TABLE behind the scene. Is there any other way to give us flexibility to really control the HTML output, for e.g i want to display using UL开发者_运维百科 tag instead of TABLE tag.
var products = new ArrayList();
products.Add("product1");
products.Add("product2");
products.Add("product3");
var builder = new StringBuilder();
foreach (var product in products)
{
builder.Append("<li>" + product + "</li>");
}
Response.Write("<ul>" + builder.ToString() + "</ul>");
You can prefer using Repeater Control
instead. With Repeater's templates, you can easily inject your html output to your output.
Here there's an exapmle of using Repeater. Actually example also try to add a table but, the topic is to show you how to use templates.
Use
Response.Write("<ul><li>item1</li><li>item1</li><li>item1</li><li>item1</li></ul>")
You get all the control u need with that
精彩评论