Source view of REPEATER.ASPX
DotNet Funda: Code Viewer
repeater.aspx | repeater.aspx.cs
Close Window  
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" Runat="Server">
    <table width="100%" cellpadding="2" cellspacing="0">
        <tr valign="top" class="ArticleTitle">
            <td style="padding-left:10px;" valign="middle">
                asp:Repeater control
                </td>
        </tr>
        <tr>
            <td class="ArticleContents">
                Repeater control displays data using user-defined layout.
            </td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" Runat="Server">
    <div class="ArticleContents">
        Repeater control displays data using user-defined layout. It just repeats the HTML and ASP.NET controls that is placed inside a template block.
        <br />
        Following are some important properties that are very useful.
        <table width="100%" class="TutoPropPlaceHolder" border="1" cellpadding="2" cellspacing="1">
            <tr>
                <td class="DemoCP">AlternatingItemTemplate</td>
                <td>
                    Template to define the rendering of every alternate item.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">FooterTemplate</td>
                <td>
                    Template to define how to render the footer.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">HeaderTemplate</td>
                <td>
                    Template to define how to render the header.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">Items</td>
                <td>
                    Gets the the collection of RepeaterItem.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">ItemTemplate</td>
                <td>
                    Template to define how items are rendered.
                </td>
            </tr>
            <tr>
                <td class="DemoCP">SeparatorTemplate</td>
                <td>
                    Template to define how separator between items will be rendered.
                </td>
            </tr>
        </table>
        <!-- START - Demo Section -->
        <table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
            <tr>
                <td class="DemoTitle">
                    DEMO : Repeater
                </td>
                <td align="right">
                    <a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/controls/repeater.aspx" target="_blank">Show Source Code</a>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                        <HeaderTemplate>
                            <h3>This is the Header of the Repeater Control</h3>
                        </HeaderTemplate>
                        <AlternatingItemTemplate>
                            <table border="1" style="background-color:#c0c0c0;" width="100%">
                                <tr>
                                    <td style="width:10%;"><%# Eval("AutoID") %></td>
                                    <td style="width:25%;"><%# Eval("Name") %></td>
                                    <td style="width:40%;"><%# Eval("Address") %></td>
                                    <td style="width:10%;"><%# Eval("Phone") %></td>
                                    <td style="width:15%;"><%# Eval("City") %></td>
                                </tr>
                            </table>
                        </AlternatingItemTemplate>
                        <ItemTemplate>
                            <table border="1" width="100%">
                                <tr>
                                    <td style="width:10%;"><%# Eval("AutoID") %></td>
                                    <td style="width:25%;"><%# Eval("Name") %></td>
                                    <td style="width:40%;"><%# Eval("Address") %></td>
                                    <td style="width:10%;"><%# Eval("Phone") %></td>
                                    <td style="width:15%;"><%# Eval("City") %></td>
                                </tr>
                            </table>
                        </ItemTemplate>
                        <SeparatorTemplate>
                            <hr />
                        </SeparatorTemplate>
                    </asp:Repeater>
                    
                     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:ConnStr %>'
                     SelectCommand="Select * FROM SampleForTutorials ORDER BY [Name]">
                     </asp:SqlDataSource>
                     <asp:Literal ID="litNotice" runat="server"></asp:Literal>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <!-- START - Server Side Code -->
                    <pre>    
        // Repeater control /////////////////////////////                    
        &lt;asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"&gt;
        &lt;HeaderTemplate&gt;
            &lt;h3&gt;This is the Header of the Repeater Control&lt;/h3&gt;
        &lt;/HeaderTemplate&gt;
        &lt;AlternatingItemTemplate&gt;
            &lt;table border="1" style="background-color:#c0c0c0;" width="100%"&gt;
                &lt;tr&gt;
                    &lt;td style="width:10%;"&gt;&lt;%# Eval("AutoID") %&gt;&lt;/td&gt;
                    &lt;td style="width:25%;"&gt;&lt;%# Eval("Name") %&gt;&lt;/td&gt;
                    &lt;td style="width:40%;"&gt;&lt;%# Eval("Address") %&gt;&lt;/td&gt;
                    &lt;td style="width:10%;"&gt;&lt;%# Eval("Phone") %&gt;&lt;/td&gt;
                    &lt;td style="width:15%;"&gt;&lt;%# Eval("City") %&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/AlternatingItemTemplate&gt;
        &lt;ItemTemplate&gt;
            &lt;table border="1" width="100%"&gt;
                &lt;tr&gt;
                    &lt;td style="width:10%;"&gt;&lt;%# Eval("AutoID") %&gt;&lt;/td&gt;
                    &lt;td style="width:25%;"&gt;&lt;%# Eval("Name") %&gt;&lt;/td&gt;
                    &lt;td style="width:40%;"&gt;&lt;%# Eval("Address") %&gt;&lt;/td&gt;
                    &lt;td style="width:10%;"&gt;&lt;%# Eval("Phone") %&gt;&lt;/td&gt;
                    &lt;td style="width:15%;"&gt;&lt;%# Eval("City") %&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;
        &lt;/ItemTemplate&gt;
    &lt;/asp:Repeater&gt;
    
    
    
    // SqlDataSource control /////////////////////////////
     &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='&lt;%$ ConnectionStrings:ConnStr %&gt;'
     SelectCommand="Select * FROM SampleForTutorials ORDER BY [Name]"&gt;
     &lt;/asp:SqlDataSource&gt;
                    
                    </pre> 
                    <!-- END - Server Side Code -->
                </td>
            </tr>
        </table>
        <!-- END - Demo Section -->
        </div>
    <br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" Runat="Server">
</asp:Content>

Go Top