Reputation: 117
I want to create dynamic divs in a ASP.NET application.
protected void Page_Load(object sender, EventArgs e)
{
List<produkt> produkte = Repository.GetProductsRanged(0, 9).ToList();
}
As you can see, there is a of products (10 elements) and I want to put some of there attributes in divs. Every product should have it owns div. How can I do this dynamicaly?
Thanks in advance!
Upvotes: 0
Views: 513
Reputation: 4855
If you don't want to use a repeater:
foreach (produkt prod in produkte)
{
HtmlGenericControl div = new HtmlGenericControl("div");
div.Attributes["one"] = "one";
div.Attributes["two"] = "two";
this.Form.Controls.Add(div);
}
Upvotes: 0