ankitweblogic logo
W e b t u t o r i a l s

Website

ASP.NET Introduction

ASP.NET Web Forms

Standard Controls

Label Control

TextBox Control

Image Control

Button Controls

Redirecting User

Using HyperLinks

RadioButton Control

RadioButtonList

CheckBox Control

CheckBoxList Control

DropDownList

ListBox Control

ImageMap Control

Master Page

View State

Event-Driven Programming

IsPostBack

ASP.NET Page Structure

Visibility of Controls

Formatting Controls

Applying CSS

Dynamic CSS

Using Style Class

Themes and Skins

Panel Control

PlaceHolder Control

AdRotator Control

Calendar Control

Validation Controls

Page Navigation

User Control

Separating Code-Presentation

Overview of ADO.NET

Data Binding

DataBinding List Control

Data Binding

When you develop a database-driven ASP.NET application, you need to bind the data stored in a database table to one or more controls on the page so that it can be displayed to the user. Data binding refers to the process of dynamically assigning a value to a property of a control at runtime.

Example 6: Data Binding

Output:
Ouput

Binding Data to a Repeater Control
The Repeater control is used to display data from a database.
Example 7: Repeater Control

Output:
Ouput

Applying Templates
The Repeater control has no user interface of its own like say a TextBox control. A template is used to control formatting. The Repeater control supports five types of templates:
• HeaderTemplate: It controls how the header of the control is formatted.
• ItemTemplate: It controls how each item shown by the control is formatted.
• AlternatingItemTemplate: It controls how alternating items shown by the control are formatted.
• SeparatorTemplate: It displays a separator between each item displayed by the control.
• FooterTemplate: It controls how the footer of the control is formatted.

You can place HTML tags, other controls, and even ASP.NET inline code within templates. Suppose you had to show items in blue and alternating items in red, you would write the following code: