| Author: Ratheesh 05 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
The Repeater control is used to display a repeated list of items that are bound to the control. The Repeater control may be bound to a database table, an XML file, or another list of items. Here we will show how to bind an XML file to a Repeater control.
We will use the following XML file in our examples ("cdcatalog.xml"):
<?xml version="1.0" encoding="ISO-8859-1"?><catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>9.90</price> <year>1988</year> </cd> <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <country>USA</country> <company>RCA</company> <price>9.90</price> <year>1982</year> </cd> <cd> <title>Still got the blues</title> <artist>Gary Moore</artist> <country>UK</country> <company>Virgin records</company> <price>10.20</price> <year>1990</year> </cd> <cd> <title>Eros</title> <artist>Eros Ramazzotti</artist> <country>EU</country> <company>BMG</company> <price>9.90</price> <year>1997</year> </cd> </catalog>
refer.......Examples http://www.w3schools.com/ASPNET/aspnet_repeater.asp
|
| Author: Rathi 05 Jul 2008 | Member Level: Gold | Rating: Points: 6 |
ASP.NET Repeater Control is one of the control in List control, the other two being DataList control and DataGrid control. List control is extensively used in web applications to show a list of data such as strings or data items from the database. The list of data may not be displayed in the web application because this will take more space. If you place a list control such as drop down list in a web application, you can contain all the data in one control.
ASP.NET Repeater Control is the easiest one of the list controls to create. It is simply adding a numbers of items underneath each other. This type of control will be ideally suited for displaying a list of hyperlinks in a web application. You can use the ASP.NET Repeater Control by creating templates that defines the layout of the control's content. A template can contain any grouping of HTML text and controls that are applicable on a Web Forms page. While running the application you cannot view the ASP.NET Repeater Control if not even a single template is defined, or if none of the templates contain elements.
The ASP.NET Repeater Control supports four types of templates: ItemTemplate, AlternatingItemTemplate, HeaderTemplate and FooterTemplate, and SeparatorTemplate. A ASP.NET Repeater Control does not have any default look. You have to define the way how the information should look like. Therefore, it is possible for you to display items in a ASP.NET Repeater Control in a table layout, in a comma-delimited list, in a bulleted list or in a numbered list.
The ASP.NET Repeater Control will not render the result unless you bound it to a data source through its DataSource property. The ASP.NET Repeater Control supports several events such as ItemCreated, ItemCommand, ItemDataBound, Load, and Unload. These events help developer to create an event when the user clicks the button.
try this link example:http://www.dotnet-guide.com/repeatercontrols.html
http://www.dotnetfunda.com/tutorials/controls/repeater.aspx?msel=2
|
| Author: Ebenezer 08 Jul 2008 | Member Level: Silver | Rating: Points: 6 |
hi
One of important goals of any application development process is making data presentation richer. ASP.NET 2.0 provides many server controls which render data in different rich formats and styles. For example, DataGrid control is suitable in many scenarios where you wish to display data in a grid like representation for easy understanding. Similarly, if the situation demands for rendering list like data, you can consider using of DataLists and Repeater server controls.
Repeater control is a container control which is template based with no basic rendering of its own. This way, you define layout for the Repeater control by creating different templates based on your needs. You can create different kinds of lists using Repeater control including Table, Comma-separated list and XML formatted list.
Repeater Control Templates Repeater controls provides different kinds of templates which helps in determining the layout of control's content. Templates generate markup which determine final layout of content.
Repeater control is an iterative control in the sense it loops each record in the DataSource and renders the specified template (ItemTemplate) for each record in the DataSource collection. In addition, before and after processing the data items, the Repeater emits some markup for the header and the footer of the resulting structure
Repeater control supports five templates which are as follows:
ItemTemplate
AlternatingItemTemplate
HeaderTemplate
FooterTemplate
SeparatorTemplate
ItemTemplate: ItemTemplate defines how the each item is rendered from data source collection.
AlternatingItemTemplate: AlternatingItemTemplates define the markup for each Item but for AlternatingItems in DataSource collection like different background color and styles.
HeaderTemplate: HeaderTemplate will emit markup for Header element for DataSource collection
FooterTemplate: FooterTemplate will emit markup for footer element for DataSource collection
SeparatorTemplate: SeparatorTemplate will determine separator element which separates each Item in Item collection. Usually, SeparateTemplate will be <br> html element or <hr> html element.
DataBinding in Repeater Control Like any other Data Bound control, Repeater control supports DataSource property which allows you to bind any valid DataSource like sqlDataSource, XML file or any datasets which implements ICollection, IEnumerable or IListSource Interfaces.
The data in DataSource is bound to Repeater using its DataBind Method. Once the data is bound, the format of each data item is defined by a template like ItemTemplate.
Adding Repeater server control to ASP.NET page Add any Data Source control to the page such as sqlDataSource or AccessDataSource. Configure Data Source control such that you specify connection information and perform query.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode] FROM [Customers]"></asp:SqlDataSource>
Drag and Drop Repeater control from Data section of the Toolbox onto the page.
<asp:Repeater ID="Repeater1" DataSourceID="SqlDataSource1" runat="server" </asp:Repeater>
Set the DataSourceID property of Repeater Control to newly configured sqlDataSource control as shown above.
Add an <ItemTemplate> element into the page as a child of the Repeater control. The Repeater control must contain at least an ItemTemplate that in turn contains data-bound controls in order for the control to render at run time.
Embed HTML markup and Web server controls or HTML server controls to the ItemTemplate to render data at run time
Bind the child controls to data from the query using the Eval data-binding function.
Following example shows how to use Repeater control to display data in a HTML table.
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <HeaderTemplate> <table border="1" cellpadding="5" cellspacing="2"> <tr bgcolor="gray"> <td><b>CompanyName</b> </td> <td><b>City</b></td> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td> <%#DataBinder.Eval(Container.DataItem, "CompanyName")%> </td> <td> <%#DataBinder.Eval(Container.DataItem, "City")%> </td> </tr> </ItemTemplate> <AlternatingItemTemplate > <tr bgcolor="aqua" > <td> <%#DataBinder.Eval(Container.DataItem, "CompanyName")%> </td> <td> <%#DataBinder.Eval(Container.DataItem, "City")%> </td> </tr> </AlternatingItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode] FROM [Customers]"></asp:SqlDataSource>
The Databinder.Eval method uses reflection to parse and evaluate a data-binding expression against an object at run time; in this case the object is our Repeater. So this line of code:
<%#DataBinder.Eval(Container.DataItem, "CompanyName")%>
regards
|
| Author: Ashok 15 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
The Repeater control is used to display a repeated list of items that are bound to the control.
The Repeater Web server control is a data-bound container control that produces a list of individual items. You define the layout of individual items on a Web page using templates. When the page runs, the control repeats the layout for each item in the data source.
|
| Author: Ashok 15 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
The Repeater control is a data-bound control that uses templates to display data. The Repeater control in ASP.NET is a data-bound container control that can be used to automate the display of a collection of repeated list items. These items can be bound to either of the following data sources:
Database Table XML File
|
| Author: Ashok 15 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
In a Repeater control, the data is rendered as DataItems that are defined using one or more templates. You can even use HTML tags such as <li>, <ul>, or <div> if required. Similar to the DataGrid, DataList, or GridView controls, the Repeater control has a DataSource property that is used to set the DataSource of this control to any ICollection, IEnumerable, or IListSource instance. Once this is set, the data from one of these types of data sources can be easily bound to the Repeater control using itsDataBind() method.
However, the Repeater control by itself does not support paging or editing of data. The Repeater control is light weight and does not contain so many features as the DataGrid contains. However, it enables you to place HTML code in its templates. It is great in situations where you need to display the data quickly and format the data to be displayed easily.
|
| Author: UltimateRengan 22 Jul 2008 | Member Level: Diamond | Rating: Points: 1 |
Bind a DataSet to a Repeater Control The Repeater control is used to display a repeated list of items that are bound to the control. The Repeater control may be bound to a database table, an XML file, or another list of items. Here we will show how to bind an XML file to a Repeater control.
We will use the following XML file in our examples ("cdcatalog.xml"):
<?xml version="1.0" encoding="ISO-8859-1"?><catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <country>UK</country> <company>CBS Records</company> <price>9.90</price> <year>1988</year> </cd> <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <country>USA</country> <company>RCA</company> <price>9.90</price> <year>1982</year> </cd> <cd> <title>Still got the blues</title> <artist>Gary Moore</artist> <country>UK</country> <company>Virgin records</company> <price>10.20</price> <year>1990</year> </cd> <cd> <title>Eros</title> <artist>Eros Ramazzotti</artist> <country>EU</country> <company>BMG</company> <price>9.90</price> <year>1997</year> </cd> </catalog>
|