Thursday, 19 April 2012

Example Reapeter in asp.net


Here Example of Repeater in asp.net How to use repeater control in asp.net .The HeaderTemplate and the FooterTemplate sections are not repeated they are not repeated in control. The ItemTemplate section will  always repeat itself according on the data fetched from the database that is called repeated. for Example-..


<asp:Repeater ID="Repeater1"  runat="server" DataSourceID="SqlDataSource1"

        EnableTheming="True">

        <HeaderTemplate>

        <table border="1" cellpadding="5" cellspacing="2">

        <tr bgcolor="white">

        <td><b>ID</b>

        </td>

        <td><b>Name</b></td>

        <td><b>Address</b></td>

        <td><b>Mobile_No</b></td>

        </tr>

        </HeaderTemplate>

         <ItemTemplate>

         <tr>

         <td>

         <%#DataBinder.Eval(Container.DataItem, "id")%>

         </td>

              <td>

         <%#DataBinder.Eval(Container.DataItem, "name")%>   

             </td>

             <td>

         <%#DataBinder.Eval(Container.DataItem, "adress")%>   

             </td>

             <td>

         <%#DataBinder.Eval(Container.DataItem, "mobile_no")%>   

             </td>

              </tr>

         </ItemTemplate>

         <AlternatingItemTemplate >

         <tr bgcolor="green" style=" background-color :Maroon">

         <td>

         <%#DataBinder.Eval(Container.DataItem, "id")%>

         </td>

             <td>

         <%#DataBinder.Eval(Container.DataItem, "name")%>   

             </td>

             <td>

         <%#DataBinder.Eval(Container.DataItem, "adress")%>   

             </td>

             <td>

         <%#DataBinder.Eval(Container.DataItem, "mobile_no")%>   

             </td>

         </tr>

         </AlternatingItemTemplate>

         <FooterTemplate>

         </table>

         </FooterTemplate>

          </asp:Repeater>

             <asp:SqlDataSource ID="SqlDataSource1" runat="server"

            ConnectionString="<%$ ConnectionStrings:con %>" SelectCommand="SELECT [id], [name], [adress] ,[Mobile_no] FROM [panku]"></asp:SqlDataSource>




No comments:

Post a Comment

What is ASP.NET? Components of ASP.NET

ASP.Net Definition -It is used for creating web-based applications.ASP.Net is a web development platform provided by Microsoft. ASP.NET i...