Question

I'm working on a webshop and I want to generate some HTML where I can put the data that I retrieve from a database.

I loop through the list of movies with this code

foreach (Film f in listFilm )
{
  Response.Write(f.id);
  Response.Write(f.name);
}

What's the best way I should follow to generate this html code (with the data from the database included?)

<div class="grid_1_of_5 images_1_of_5">
  <a href="ArtikelDetail.aspx"><img src="images/beauty_and_the_beast.jpg" alt="" /></a>
  <h2 id="film1" runat="server"><a href="ArtikelDetail.aspx">Beauty and beast</a></h2>
  <div class="add-cart price-details">
    <h4><a id="linkFilm1" runat="server" href="ArtikelDetail.aspx">Bekijk details</a></h4>
  </div>
  <div class="clear"></div>
</div>
Was it helpful?

Solution

use an asp repeater... then if you want to format based on the data leverage row data bound event... it looks like you would need to have an on rowdatabound handler or get more data from the start to handle pricing

OTHER TIPS

Create a Web server control, you can create the HTML at runtime and reuse it as well. Pass the object into the control and override the render and you will get the html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top