Repeater Control have 5 entity which you can say templates.
1. Header Template 2. Item Template 3. AlternatingItemTemplate 4. Seperator Template 5. Footer Template
1. ItemTemplate: ItemTemplate defines how the each item is rendered from data source.
2. AlternatingItemTemplate: AlternatingItemTemplates is used to change the styles of Alternate Items in Data Source collection
3. Header Template: Header Template is used for Header text for Data Source collection and apply styles for header text.
4. Footer Template: Footer Template is used to display footer element for Data Source collection.
5. SeparatorTemplate: SeparatorTemplate will determine separator element which separates each Item in Item collection.
Design View:
01 | <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> |
07 | < title >Hightechnology Repeater Control Example</ title > |
10 | < form id = "form1" runat = "server" > |
11 | < div style = "width:800px; margin:0 auto;" > |
12 | < asp:Repeater ID = "Repeater1" runat = "server" > |
14 | < table style = "border:solid 1px black" > |
16 | < td style = "width:100px" > |
19 | < td style = "width:100px" > |
22 | < td style = "width:100px" > |
25 | < td style = "width:100px" > |
33 | < table style = "border:solid 1px black" > |
35 | < td style = "width:100px" > |
36 | < asp:Label ID = "empid" Text='<%#Eval("empno") %>' runat="server"></ asp:Label > |
38 | < td style = "width:100px" > |
39 | < asp:Label ID = "empname" Text='<%#Eval("ename") %>' runat="server"></ asp:Label > |
41 | < td style = "width:100px" > |
42 | < asp:Label ID = "salary" Text='<%#Eval("basic") %>' runat="server"></ asp:Label > |
44 | < td style = "width:100px" > |
45 | < asp:Label ID = "designation" Text='<%#Eval("job") %>' runat="server"></ asp:Label > |
Code View:
02 | using System.Collections.Generic; |
06 | using System.Web.UI.WebControls; |
08 | using System.Data.SqlClient; |
11 | public partial class _Default : System.Web.UI.Page |
13 | SqlConnection con = new SqlConnection( "Data Source=hightechnology;Initial Catalog=session;Integrated Security=true" ); |
14 | protected void Page_Load( object sender, EventArgs e) |
18 | public void Binddata() |
21 | SqlCommand cmd = new SqlCommand( "select * from emp" , con); |
22 | DataSet ds = new DataSet(); |
23 | SqlDataAdapter da = new SqlDataAdapter(cmd); |
25 | Repeater1.DataSource = ds; |
No comments:
Post a Comment