Templates:
There are 5 templates available for a Repeater:
1. Header Template2. ItemTemplate3. AlternatingItemTemplate4. SeparatorTemplate
5. FooterTemplateLet me discuss these templates in details:
HeaderTemplate: It is used to specify an optional header row. It is used to determine the content and layout of the list header.
ItemTemplate :It is used to define the content and layout of items within the list.AlternatingItemTemplate: This template is used for elements that are rendered every second row of data. This allows you to alternate background colors.
SeparatorTemplate: The SeparatorTemplate is rendered between each row.FooterTemplate: It is used to specify an optional footer row. It is used to determine the content and layout of the list footer.
All these 5 templates will be placed within the Repeater .
HeaderTemplate


AlternatingItemTemplate

FooterTemplate

SeperatorTemplate

Link Buttons:
These link Button placed outside of the repeator control

Pagination in Repeater:
Repeater doesn’t support Paging directly. But we can implement Paging in Repeater by using PagedDataSource.
PagedDataSource:
This class comes from the System.Data.Web.UI.WebControls namespace, so we need not import any additional namespace to the page.
This class encapsulates the paging related properties of a data-bound control.
Few properties of PagedDataSource class are as follows:
1. PageSize - This property defines how many records are displayed on a page and it takes an integer (by default it's set at 10).
2. AllowPaging - This property determines whether the paging should be turned on or off (Boolean "true" or "false"). By default it is set to "false".
3. CurrentPageIndex - This gets/sets the current page number. By default it returns 0.
4. PageCount - Returns the total number of pages that are available.
5. DataSource - The value of this property will be the source of the data which we want to page.
6. IsFirstPage - Returns "true" or "false". It depends on whether the current page is the first page in the series.
7. IsLastPage -- Returns "true" or "false". It depends on whether the current page is the last page in the series.
Connection Object and Property Decleration follows:

Code for Page_Load Event

Code written in BringData() method

Here I have created an instance of the PagedDataSource class. In the next line, I had set the DataSource In the following line the AllowPaging property is to "true". And on the next line the PageSize property is set to 3.

Contents of the Table tblUser

Output
The output is as follows:

Conclusion
This is all about Repeater Control. Hope u all enjoy reading it. Please provide me feedback on it, if any improvements required.
No comments:
Post a Comment