0

I'm quite new to asp.net and vb.net, so my apologies if I do not use the correct terminology here.

I have a database table and for each row in a returned dataset from that table I want to produce some HTML code eg:

<div>
    <img src="SOURCE" />
    <h1>Row1</h1>
    <input type="button" />
    <input type="button" />
</div
<div>
    <img src="SOURCE" />
    <h1>Row2</h1>
    <input type="button" />
    <input type="button" />
</div

What would be the best way to do this? Do I simply pull back an object with the entire data and then write a foreach loop to iterate through each row and insert a string to the page, or should I be looking to use a user control?

我想我正在尝试制作一种论坛列表页面,并希望获取数据库中具有特定条目的所有主题,然后在带有一些输入控件和图像的页面上显示该列表。我还想添加分页;所以在任何时候只显示10个帖子,然后能够分页到下一页。

如果我不是很清楚,我再次道歉,但我有点难以理解解决这个问题的最佳方法。

4

2 回答 2

4

您可以使用Repeater

   <asp:Repeater id="Repeater1" runat="server">
      <ItemTemplate>
          <img src="SOURCE" />
          <h1>Row<%# Container.ItemIndex %></h1>
          <input type="button" />
          <input type="button" />
      </ItemTemplate>
   </asp:Repeater>
于 2013-03-29T18:21:18.730 回答
-2

如果您希望重复任何代码块。试试我使用的这段代码..

显示任意 div 3 次的示例代码

<% For i as Integer = 1 To 3%>
 <div>
    <img src="SOURCE" />
    <h1>Row1</h1>
    <input type="button" />
    <input type="button" />  
</div> <% Next %>
于 2013-03-29T18:24:49.977 回答