views:

1072

answers:

1

Hi, Im a VB.NET beginnger, can anyone tell me how I can dynamically add a div table row or how I can loop a section of html? thanks.

+1  A: 

I'm making a few assumptions about what your doing (such as you're using ASP.Net) but you can use the Repeater control to loop a section of HTML.

<asp:Repeater ID="myRepeater" runat="server">
    <ItemTemplate>
           <div>What you want to loop here</div>
    </ItemTemplate>
</asp:Repeater>

But of course you'll have to databind the repeater for it to loop through the items that it's databound to. You could also do an inline loop:

<% for (int i = 0; i < 5; i++)
   { %>
           <div>Something repeated here</div>
<% } %>

You'll have to put the for loop into VB syntax of course.

Max Schmeling
Brilliant, thanks. I will go for the inline loop, but is there a way to pull in a declared value, declared in the vb code file? ie for i = 0 to TotalPeople
Just put a property in the code behind of the page and then you can access that property like normal from the inline loop (this.MyProperty)
Max Schmeling