开发者

How to repeat with repeater for 10 times the same code?

<asp:Repeater id="rptExcelField" runat="server">
    <HeaderTemplate>
        <table style="width:100%;" id="mainTable">
    </HeaderTemplate>         
    <ItemTemplate>
        <tr>
            <td class="style1">
                <asp:Label ID="lblField" runat="server" Text="Polje:" CssClass="textType"></asp:Label>
            </td>                
            <td class="style2">
                <asp:TextBox ID="txtField" runat="server" Width="436px" MaxLength="45" 
                    CssClass="inputType"></asp:TextBox>
                <asp:DropDownList ID="ddlInputType" runat="server" oninit="ddlInputType_Init" 
                    AutoPostBack="True" 
                    onselectedindexchanged="ddlInputType_SelectedIndexChanged">                        
                </asp:DropDownList>     
            </td>
            <td class="style3">
                <asp:RequiredFieldValidator ID="rfvName" runat="server" ControlToValidate="txtName"
                    ErrorMessage="*" CssClass="validator"></asp:RequiredFieldValidator>
            </td>
        </tr>
    </ItemTemplate>         
    <FooterTemplate>
        </table>
    </FooterTemplate>         

How to repeat with repeater for 10 times t开发者_如何学Gohe same code?


Realistically, you just need to bind the repeater to something with 10 items in it. Maybe not the best approach to simply dump 10 iterations on screen, but to answer your question specifically:

Code-behind:

protected void Page_Load(object sender, EventArgs e)
{
    List<int> data = new List<int>();
    for(int i=0; i<10; i++)
    {
        data.Add(i);
    }

    rptExcelField.DataSource = data;
    rptExcelField.DataBind();
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜