SlideShare a Scribd company logo
2
Most read
5
Most read
14
Most read
ASP.NET AdRotator Control
Definition and Usage 
The AdRotator control is used to display a sequence of ad 
images. 
This control uses an XML file to store the ad information. 
The XML file must begin and end with an 
<Advertisements> tag. Inside the <Advertisements> tag 
there may be several <Ad> tags which defines each ad. 
The AdRotator Control presents ad images each time a user enters or refreshes a webpage. 
When the ads are clicked, it will navigate to a new Web location. Each time the page is loaded 
into the browser, an ad is randomly selected from a predefined list. Previously the predefined 
list means an XML File, which contains the information about the ads to be displayed. But in 
Asp.Net 2.0 we can maintain the list in any data source. In this article, we explained the 
AdRotator control to fetch ads information from both database and XML file, and display those 
ads in randomly with the help of Timer control. You can say it as an AJAX AdRotator Control.
The predefined elements inside the <Ad> tag are listed 
below: 
Element Description 
<ImageUrl> 
Optional. The path to the 
image file 
<NavigateUrl> 
Optional. The URL to link 
to if the user clicks the ad 
<AlternateText> 
Optional. An alternate text 
for the image 
<Keyword> 
Optional. A category for 
the ad 
<Impressions> 
Optional. The display rates 
in percent of the hits
Properties 
Property Description 
. 
N 
E 
T 
AdvertisementFile 
Specifies the path to the XML file 
that contains ad information 
1 
. 
0 
AlternateTextField 
Specifies a data field to be used 
instead of the Alt text for an ad 
2 
. 
0 
ImageUrlField 
Specifies a data field to be used 
instead of the ImageURL 
attribute for an ad 
2 
. 
0 
KeywordFilter 
Specifies a filter to limit ads after 
categories 
1 
. 
0 
NavigateUrlField 
Specifies a data field to be used 
instead of the NavigateUrl 
attribute for an ad 
2 
. 
0 
runat 
Specifies that the control is a 
server control. Must be set to 
"server" 
1 
. 
0 
Target Specifies where to open the URL 
1 
. 
0
5 
Outline 
FlagRotator.aspx 
(3 of 3 ) 
AdRotator image 
Fig. | Web Form that demonstrates the AdRotator 
web control. (Part 3 of 3. ) 
a) 
AlternateText 
displayed in a tool tip 
c) 
b) 
Add an AdRotator control named 
countryRotator. 
Add a XmlDataSource control, which 
supplies the data to the AdRotator 
control. 
Figure (a) shows the first time the page is 
requested, when the Swedish flag is 
randomly chosen. 
In the second request, as shown in Figure 
(b), the French flag is displayed. 
Figure (c) depicts the web page that loads 
when you click the French flag.
AdRotator Example: FlagRotator 
Connecting Data to an AdRotator Control 
• An XmlDataSource references an XML file containing data that will 
be used in an ASP.NET application. 
• To build this example, we first add the XML file 
AdRotatorInformation.xml to the project. 
• Right click the App_Data folder in the Solution Explorer and select 
Add Existing Item…. 
• Next, drag an AdRotator control from the Toolbox to the Web 
Form.
AdRotator and AdRepeater Control in Asp.Net for Msc CS
AdRotator Example: FlagRotator 
• From the smart-tag menu, select <New Data Source…> from the 
Choose Data Source drop-down list to start the Data Source 
Configuration Wizard. 
• Select XML File as the data-source type. Set the ID of the control 
to adXmlDataSource. 
• In the next dialog’s Data File section, click Browse… and, in the 
Select XML File dialog, locate and select the XML file you added 
to the App_Data folder.
Examining an XML File Containing Advertisement 
Information 
Any XML document used with an AdRotator control—must contain one 
Advertisements root element. 
Within that element can be as many Ad elements as you need. Each Ad element is 
similar to the following: 
<Ad> 
<ImageUrl>Images/france.png</ImageUrl> 
<NavigateUrl>https://www.cia.gov/library/publications/ 
the-world-factbook/geos/fr.html 
</NavigateUrl> 
<AlternateText>France Information</AlternateText> 
<Impressions>1</Impressions> 
</Ad>
Element ImageUrl specifies the path (location) of the 
advertisement’s image. 
Element NavigateUrl specifies the URL for the web 
page that loads when a user clicks the advertisement. 
The AlternateText element nested in each Ad element 
contains text that displays in place of the image when the 
browser cannot display the image. 
The Impressions element specifies how often a 
particular image appears, relative to the other images. In 
our example, the advertisements display with equal 
probability, because the value of each Impressions 
element is set to 1.
AdRotator and AdRepeater Control in Asp.Net for Msc CS
AdRotator and AdRepeater Control in Asp.Net for Msc CS
ASP.NET Repeater Control
Data Controls 
ASP.NET comes with two sets of data-aware controls: 
the data-bound and the data source controls. 
Data-bound controls 
These are used to display and edit data. The 
GridView, DataList, ListView, and 
Repeater are all able to display multiple records 
at the same time, whereas the DetailsView and 
the FormView are designed to show a single record 
at a time. The DataPager is used to provide 
paging capabilities to the ListView controls.
Definition and Usage 
 Repeater – It gives you the greatest flexibility in terms 
of the HTML that you output to the browser as the 
control by itself does not add any HTML to the page 
output. The control has no built-in capabilities for the 
paging, sorting and modification of data. It is often used 
when you need precise control over the markup that is 
generated by the control. As such, it’s often used for 
HTML ordered or unordered lists (<ol> and <ul>), etc.
Repeater has 5 inline template to format it: 
1. <HeaderTemplate> 
2. <FooterTemplate> 
3. <ItemTemplate> 
4. <AlternatingItemTemplate> 
5. <SeperatorTemplate> 
6. <AlternatingItemTemplate> 
HeaderTemplate: This template is used for elements that you want to render once before your 
ItemTemplate section. 
FooterTemplate: - This template is used for elements that you want to render once after your 
ItemTemplate section. 
ItemTemplate: This template is used for elements that are rendered once per row of data. It is used to 
display records 
AlternatingItemTemplate: This template is used for elements that are rendered every second row of 
data. This allows you to alternate background colors. It works on even number of records only. 
SeperatorTemplate: It is used for elements to render between each row, such as line breaks.
How to use a Repeater Control? 
Create a new website with name RepeaterControl 
Double click the web.config file and write following code in it:
<connectionStrings> 
<add name="constr" connectionString="initial catalog=puran; data 
source=MCN002; integrated security=sspi"/> 
</connectionStrings> 
Default.aspx file code 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" 
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<link rel="Stylesheet" type="text/css" href="StyleSheet.css" /> 
<title>Repeater Controls in ASP.NET</title> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
<asp:Repeater ID="RepeatInformation" runat="server"> 
<HeaderTemplate> 
<table class="tblcolor">
<tr> 
<b> 
<td> 
Roll No 
</td> 
<td> 
Student Name 
</td> 
<td> 
Total Fees 
</td> 
</b> 
</tr> 
</HeaderTemplate> 
<ItemTemplate> 
<tr class="tblrowcolor"> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.RollNo")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Name")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Fees")%> 
</td> 
</tr> 
</ItemTemplate> 
<SeparatorTemplate>
<hr /> 
</td> 
</tr> 
</SeparatorTemplate> 
<AlternatingItemTemplate> 
<tr> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.RollNo")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Name")%> 
</td> 
<td> 
<%#DataBinder.Eval(Container,"DataItem.Fees")%> 
</td> 
</tr> 
</AlternatingItemTemplate> 
<SeparatorTemplate> 
<tr> 
<td> 
<hr /> 
</td> 
<td> 
<hr /> 
</td> 
<td> 
<hr /> 
</td> 
</tr> 
</SeparatorTemplate> 
<FooterTemplate> 
<tr> 
<td>
Code behind file code 
using System; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
using System.Data.SqlClient; 
public partial class _Default : System.Web.UI.Page 
{ 
SqlConnection con; 
SqlCommand cmd = new SqlCommand(); 
protected void Page_Load(object sender, EventArgs e) 
{ 
con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); 
cmd.Connection = con; 
cmd.CommandText = "select * from student"; 
con.Open(); 
RepeatInformation.DataSource = cmd.ExecuteReader(); 
RepeatInformation.DataBind(); 
con.Close(); 
} 
}
AdRotator and AdRepeater Control in Asp.Net for Msc CS
Thanvi

More Related Content

What's hot (20)

PPTX
Cookie & Session In ASP.NET
ShingalaKrupa
 
PPTX
ASP.NET Page Life Cycle
Abhishek Sur
 
PPT
Cookies in servlet
chauhankapil
 
PPTX
.Net Assemblies
Muhammad Kamran Rafi
 
PPTX
Common language runtime clr
SanSan149
 
PDF
Wrapper classes
Ravi_Kant_Sahu
 
PPT
Data abstraction and object orientation
Hoang Nguyen
 
PPT
Java interfaces
Raja Sekhar
 
PPT
Uml - An Overview
Raj Thilak S
 
PPTX
Ado.Net Tutorial
prabhu rajendran
 
PPTX
Activity diagram
bhupendra kumar
 
PPT
Developing an ASP.NET Web Application
Rishi Kothari
 
PPT
Generics in java
suraj pandey
 
PPTX
Common Standards in Cloud Computing
mrzahidfaiz.blogspot.com
 
PPTX
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Awt, Swing, Layout managers
swapnac12
 
PPTX
Adrotator in asp
Sireesh K
 
PDF
Asp .net web form fundamentals
Gopal Ji Singh
 
Cookie & Session In ASP.NET
ShingalaKrupa
 
ASP.NET Page Life Cycle
Abhishek Sur
 
Cookies in servlet
chauhankapil
 
.Net Assemblies
Muhammad Kamran Rafi
 
Common language runtime clr
SanSan149
 
Wrapper classes
Ravi_Kant_Sahu
 
Data abstraction and object orientation
Hoang Nguyen
 
Java interfaces
Raja Sekhar
 
Uml - An Overview
Raj Thilak S
 
Ado.Net Tutorial
prabhu rajendran
 
Activity diagram
bhupendra kumar
 
Developing an ASP.NET Web Application
Rishi Kothari
 
Generics in java
suraj pandey
 
Common Standards in Cloud Computing
mrzahidfaiz.blogspot.com
 
Exception handling in ASP .NET
baabtra.com - No. 1 supplier of quality freshers
 
Awt, Swing, Layout managers
swapnac12
 
Adrotator in asp
Sireesh K
 
Asp .net web form fundamentals
Gopal Ji Singh
 

Similar to AdRotator and AdRepeater Control in Asp.Net for Msc CS (20)

PDF
ASP.net Image Slideshow
Hock Leng PUAH
 
PPSX
06 asp.net session08
Vivek Singh Chandel
 
PPTX
Ch 7 data binding
Madhuri Kavade
 
PPT
Data controls ppt
Iblesoft
 
PPS
07 asp.net session10
Niit Care
 
PPT
Synapse india dotnet development web approch
Synapseindiappsdevelopment
 
PPT
Synapse india reviews sharing chapter 23 – asp.net-part2
Synapseindiappsdevelopment
 
PPTX
Chapter 10
application developer
 
PPS
06 asp.net session08
Mani Chaubey
 
PPSX
07 asp.net session10
Vivek Singh Chandel
 
PPS
07 asp.net session10
Mani Chaubey
 
PPTX
Microsoft asp.net online training
training3
 
PPTX
Microsoft asp.net online training
training13acutesoft
 
PPT
Chapter12 (1)
Rajalaxmi Pattanaik
 
PPTX
Chapter 15
application developer
 
PPTX
Standard control in asp.net
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Building Rich Internet Applications Using Microsoft Silverlight 2, Part 2
goodfriday
 
PPTX
MICROSOFT ASP.NET ONLINE TRAINING
Santhosh Sap
 
PPTX
MICROSOFT ASP.NET ONLINE TRAINING
training3
 
PPTX
Microsoft asp.net online training
Santhosh Reddy
 
ASP.net Image Slideshow
Hock Leng PUAH
 
06 asp.net session08
Vivek Singh Chandel
 
Ch 7 data binding
Madhuri Kavade
 
Data controls ppt
Iblesoft
 
07 asp.net session10
Niit Care
 
Synapse india dotnet development web approch
Synapseindiappsdevelopment
 
Synapse india reviews sharing chapter 23 – asp.net-part2
Synapseindiappsdevelopment
 
06 asp.net session08
Mani Chaubey
 
07 asp.net session10
Vivek Singh Chandel
 
07 asp.net session10
Mani Chaubey
 
Microsoft asp.net online training
training3
 
Microsoft asp.net online training
training13acutesoft
 
Chapter12 (1)
Rajalaxmi Pattanaik
 
Building Rich Internet Applications Using Microsoft Silverlight 2, Part 2
goodfriday
 
MICROSOFT ASP.NET ONLINE TRAINING
Santhosh Sap
 
MICROSOFT ASP.NET ONLINE TRAINING
training3
 
Microsoft asp.net online training
Santhosh Reddy
 
Ad

Recently uploaded (20)

PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Neurodivergent Friendly Schools - Slides from training session
Pooky Knightsmith
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
Ad

AdRotator and AdRepeater Control in Asp.Net for Msc CS

  • 2. Definition and Usage The AdRotator control is used to display a sequence of ad images. This control uses an XML file to store the ad information. The XML file must begin and end with an <Advertisements> tag. Inside the <Advertisements> tag there may be several <Ad> tags which defines each ad. The AdRotator Control presents ad images each time a user enters or refreshes a webpage. When the ads are clicked, it will navigate to a new Web location. Each time the page is loaded into the browser, an ad is randomly selected from a predefined list. Previously the predefined list means an XML File, which contains the information about the ads to be displayed. But in Asp.Net 2.0 we can maintain the list in any data source. In this article, we explained the AdRotator control to fetch ads information from both database and XML file, and display those ads in randomly with the help of Timer control. You can say it as an AJAX AdRotator Control.
  • 3. The predefined elements inside the <Ad> tag are listed below: Element Description <ImageUrl> Optional. The path to the image file <NavigateUrl> Optional. The URL to link to if the user clicks the ad <AlternateText> Optional. An alternate text for the image <Keyword> Optional. A category for the ad <Impressions> Optional. The display rates in percent of the hits
  • 4. Properties Property Description . N E T AdvertisementFile Specifies the path to the XML file that contains ad information 1 . 0 AlternateTextField Specifies a data field to be used instead of the Alt text for an ad 2 . 0 ImageUrlField Specifies a data field to be used instead of the ImageURL attribute for an ad 2 . 0 KeywordFilter Specifies a filter to limit ads after categories 1 . 0 NavigateUrlField Specifies a data field to be used instead of the NavigateUrl attribute for an ad 2 . 0 runat Specifies that the control is a server control. Must be set to "server" 1 . 0 Target Specifies where to open the URL 1 . 0
  • 5. 5 Outline FlagRotator.aspx (3 of 3 ) AdRotator image Fig. | Web Form that demonstrates the AdRotator web control. (Part 3 of 3. ) a) AlternateText displayed in a tool tip c) b) Add an AdRotator control named countryRotator. Add a XmlDataSource control, which supplies the data to the AdRotator control. Figure (a) shows the first time the page is requested, when the Swedish flag is randomly chosen. In the second request, as shown in Figure (b), the French flag is displayed. Figure (c) depicts the web page that loads when you click the French flag.
  • 6. AdRotator Example: FlagRotator Connecting Data to an AdRotator Control • An XmlDataSource references an XML file containing data that will be used in an ASP.NET application. • To build this example, we first add the XML file AdRotatorInformation.xml to the project. • Right click the App_Data folder in the Solution Explorer and select Add Existing Item…. • Next, drag an AdRotator control from the Toolbox to the Web Form.
  • 8. AdRotator Example: FlagRotator • From the smart-tag menu, select <New Data Source…> from the Choose Data Source drop-down list to start the Data Source Configuration Wizard. • Select XML File as the data-source type. Set the ID of the control to adXmlDataSource. • In the next dialog’s Data File section, click Browse… and, in the Select XML File dialog, locate and select the XML file you added to the App_Data folder.
  • 9. Examining an XML File Containing Advertisement Information Any XML document used with an AdRotator control—must contain one Advertisements root element. Within that element can be as many Ad elements as you need. Each Ad element is similar to the following: <Ad> <ImageUrl>Images/france.png</ImageUrl> <NavigateUrl>https://www.cia.gov/library/publications/ the-world-factbook/geos/fr.html </NavigateUrl> <AlternateText>France Information</AlternateText> <Impressions>1</Impressions> </Ad>
  • 10. Element ImageUrl specifies the path (location) of the advertisement’s image. Element NavigateUrl specifies the URL for the web page that loads when a user clicks the advertisement. The AlternateText element nested in each Ad element contains text that displays in place of the image when the browser cannot display the image. The Impressions element specifies how often a particular image appears, relative to the other images. In our example, the advertisements display with equal probability, because the value of each Impressions element is set to 1.
  • 14. Data Controls ASP.NET comes with two sets of data-aware controls: the data-bound and the data source controls. Data-bound controls These are used to display and edit data. The GridView, DataList, ListView, and Repeater are all able to display multiple records at the same time, whereas the DetailsView and the FormView are designed to show a single record at a time. The DataPager is used to provide paging capabilities to the ListView controls.
  • 15. Definition and Usage  Repeater – It gives you the greatest flexibility in terms of the HTML that you output to the browser as the control by itself does not add any HTML to the page output. The control has no built-in capabilities for the paging, sorting and modification of data. It is often used when you need precise control over the markup that is generated by the control. As such, it’s often used for HTML ordered or unordered lists (<ol> and <ul>), etc.
  • 16. Repeater has 5 inline template to format it: 1. <HeaderTemplate> 2. <FooterTemplate> 3. <ItemTemplate> 4. <AlternatingItemTemplate> 5. <SeperatorTemplate> 6. <AlternatingItemTemplate> HeaderTemplate: This template is used for elements that you want to render once before your ItemTemplate section. FooterTemplate: - This template is used for elements that you want to render once after your ItemTemplate section. ItemTemplate: This template is used for elements that are rendered once per row of data. It is used to display records AlternatingItemTemplate: This template is used for elements that are rendered every second row of data. This allows you to alternate background colors. It works on even number of records only. SeperatorTemplate: It is used for elements to render between each row, such as line breaks.
  • 17. How to use a Repeater Control? Create a new website with name RepeaterControl Double click the web.config file and write following code in it:
  • 18. <connectionStrings> <add name="constr" connectionString="initial catalog=puran; data source=MCN002; integrated security=sspi"/> </connectionStrings> Default.aspx file code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <link rel="Stylesheet" type="text/css" href="StyleSheet.css" /> <title>Repeater Controls in ASP.NET</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Repeater ID="RepeatInformation" runat="server"> <HeaderTemplate> <table class="tblcolor">
  • 19. <tr> <b> <td> Roll No </td> <td> Student Name </td> <td> Total Fees </td> </b> </tr> </HeaderTemplate> <ItemTemplate> <tr class="tblrowcolor"> <td> <%#DataBinder.Eval(Container,"DataItem.RollNo")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Name")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Fees")%> </td> </tr> </ItemTemplate> <SeparatorTemplate>
  • 20. <hr /> </td> </tr> </SeparatorTemplate> <AlternatingItemTemplate> <tr> <td> <%#DataBinder.Eval(Container,"DataItem.RollNo")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Name")%> </td> <td> <%#DataBinder.Eval(Container,"DataItem.Fees")%> </td> </tr> </AlternatingItemTemplate> <SeparatorTemplate> <tr> <td> <hr /> </td> <td> <hr /> </td> <td> <hr /> </td> </tr> </SeparatorTemplate> <FooterTemplate> <tr> <td>
  • 21. Code behind file code using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; public partial class _Default : System.Web.UI.Page { SqlConnection con; SqlCommand cmd = new SqlCommand(); protected void Page_Load(object sender, EventArgs e) { con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString); cmd.Connection = con; cmd.CommandText = "select * from student"; con.Open(); RepeatInformation.DataSource = cmd.ExecuteReader(); RepeatInformation.DataBind(); con.Close(); } }