Home Backend Development PHP Tutorial asp.net Repeater控件的说明及详细介绍及使用方法_PHP

asp.net Repeater控件的说明及详细介绍及使用方法_PHP

Jun 01, 2016 pm 12:19 PM
asp.net repeater control

Repeater 控件不具备内置的呈现功能,这表示用户必须通过创建模板为 Repeater 控件提供布局。当该页运行时,Repeater 控件依次通过数据源中的记录为每个记录呈现一个项。

他很简单,用起来也不够强大,但是应了那句老话,杀鸡焉用牛刀,不用牛刀那用什么呢?难道我们去把鸡咬死不成?而我们在日常应用中也常常面临这样的选择,假设我们显示教复杂的数据,可以用gridview,一般复杂的用DataList,那么简单的数据呈现呢?我们就用Repeater了,因为他简单,小巧,最主要是灵活.

  我们上面说,他不具备内置的呈现功能,所以我们得用到一些模板来实现他的数据呈现.对了,说到呈现,我还得多句嘴,他没有给你添加静态项的功能,换句话说,他只跟数据库打交道,一般人他不跟你说话.

  下表描述了 Repeater 控件支持的模板。
  模板属性 说明
  ItemTemplate
  包含要为数据源中每个数据项都要呈现一次的 HTML 元素和控件。

  AlternatingItemTemplate
  包含要为数据源中每个数据项都要呈现一次的 HTML 元素和控件。通常,可以使用此模板为交替项创建不同的外观,例如指定一种与在 ItemTemplate 中指定的颜色不同的背景色。

  HeaderTemplate 和 FooterTemplate
  包含在列表的开始和结束处分别呈现的文本和控件。

  SeparatorTemplate
  包含在每项之间呈现的元素。典型的示例可能是一条直线(使用 hr 元素)。


  我们在这些模板里面定义好格式,当网页被呈现出来的时候就会比较漂亮了,当然你做得丑的话,那是不可能漂亮的了.

  另外 Item 样版必须要定义
  如果Repeater控件没有指定数据源,它将不显示,如果指定的数据源中没有数据,那么头,脚模板将继续显示。

  对于这个控件我们要讲的主要有以下几点

  1,理解该控件的几个模板
  2,简单实用 Repeater控件实现数据读取以及呈现。
  3,实现该控件的镶套使用
  4,实现数据分页(我博客上以前发布的是在repeater外面利用控件分页,但是总感觉不好看,这次我们把分页放到了页脚模板 中,以使控件更为美观)
  5,让我们的数据条目成为链接,也只有这样,他才是完整的.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Common rich text editor controls in Go language web development framework Common rich text editor controls in Go language web development framework Jun 04, 2023 am 09:10 AM

With the popularity of web applications, rich text editors have become an indispensable tool in web development. When using Go language for web development, we also need to choose a suitable rich text editor control to enrich our websites and applications. In this article, we will discuss common rich text editor controls in Go language web development. FroalaEditorFroalaEditor is a popular rich text editor control that is widely used in web development. it has modernity

How to use panel control How to use panel control Oct 10, 2023 am 09:36 AM

The steps to use the panel control are to first create a Panel control and set its width, height, background color, border color, border width and padding, create two buttons and add them to the Panel control, and finally Add the Panel control to the form.

How to make excel controls How to make excel controls Mar 20, 2024 am 09:40 AM

When we use the excel office software, if we can use some controls skillfully, it can help us create more professional effects in the excel form. For example, adding selection controls can make the form filler easily complete the form. Below, we will demonstrate how to make an excel selection control. We hope it will be helpful to you! 1. First, we create and open a blank excel table. 2. Add the "Development Tools" tab, click the file button on the upper left side, and find "Excel Options". After that, we find the development tools in the options of the custom ribbon and check it so that a check mark appears in front of it. 3. Return to the Excel work interface and you can see the "Development Tools" tab. Generally speaking, it is not

What are the nested methods of repeater? What are the nested methods of repeater? Oct 23, 2023 am 10:15 AM

Repeater nesting methods include for loop nesting, recursive methods, while loop nesting, etc. Detailed introduction: 1. For loop nesting: Use for loop to repeatedly execute the code block of a certain method. The number of repetitions can be controlled by setting the number of loops or traversing a list; 2. Recursive method: call itself inside the method to achieve the effect of repeated execution. Recursive methods need to set recursive termination conditions to avoid infinite recursion; 3. While loop nesting: use while loops to repeatedly execute the code block of a certain method, etc.

What are the common Ajax controls? Learn more about its features and capabilities What are the common Ajax controls? Learn more about its features and capabilities Jan 17, 2024 am 11:11 AM

In-depth understanding of Ajax controls: What are the common ones? Introduction: In modern Web development, Ajax (Asynchronous JavaScript and XML) has become a popular technology, which can realize partial refresh of web pages and improve user experience. In development, we usually use Ajax controls to simplify and speed up our development process. This article will take an in-depth look at Ajax controls and introduce some common controls and their functions. 1. jQueryAjax: jQueryA

What is a control What is a control Oct 28, 2022 pm 03:51 PM

Controls refer to the encapsulation of data and methods; controls can have their own properties and methods, where properties are simple visitors to the control data, and methods are some simple and visible functions of the control. The control creation process includes design, development, and debugging ;The greatest significance of creating controls is to encapsulate repetitive work, and secondly, to expand the functions of existing controls.

How to solve the problem that edge browser cannot install office controls How to solve the problem that edge browser cannot install office controls Jan 06, 2024 pm 05:01 PM

Office friends need to install the office control on the browser if they want to view the announcement file on oa. However, many users fail to install it. In fact, it is because they have not set it up. Let’s take a look at the specific method below. . The edge browser office control cannot be installed: 1. Go to edge browser->Settings->More Tools->Internet Options. 2. Click "Privacy" and uncheck "Enable pop-up blocker". 3. Add trusted sites in "Security" and add OA's address to the trusted sites. 4. Click "Custom Level" in the "Security" taskbar. 5. In "ActiveX Controls and Plug-ins", set all items to "Enabled". 6

Learn about the most popular Ajax controls! Learn about the most popular Ajax controls! Jan 17, 2024 am 09:47 AM

In Web development, Ajax technology allows asynchronous communication between the web page and the server, greatly improving the response speed and user experience of the web page. The Ajax control is a type of tool developed on this basis, which can help us implement various functions more conveniently and improve development efficiency. This article will introduce and analyze some of the more commonly used Ajax controls. 1. jQuery jQuery is currently the most popular Javascript library. Its Ajax support is very powerful and it is relatively simple to use. By Mu

See all articles