开发者

webform control to iterate X times through a template

开发者 https://www.devze.com 2023-01-05 15:00 出处:网络
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 ?

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

精彩评论

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