开发者

webform control to iterate X times through a template

Here is my problem. I need to display an html table with 9 cells in each row, how can I do it without writing every cell's html code ? I'd need something like that :

<table>开发者_高级运维;
  <tr>
    <asp:repeater runat="server" datasource="[0..9]">
     <itemtemplate>
       <td><%# Eval("value") %></td>
     </itemtemplate>
    </asp:repeater>
  </tr>
</table>

Is there any built-in asp.net control ? I don't want to build some html code in my code-behind. thanks


There sure is, Enumerable.Range. In your case it'll be

Enumerable.Range(1, 9)

You can then retrieve the current enumerator value like so

<%# Container.DataItem %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜