ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
ASP Dot Net Tutorial - Index
ASP Dot Net Tutorial - Microsofts ASP.NET
ASP Dot Net Tutorial - Begining Web Forms
ASP Dot Net Tutorial - User Controls
ASP Dot Net Tutorial - ADO .NET
ASP Dot Net Tutorial - DataBinding to WebControls
ASP Dot Net Tutorial - DataList Controls
ASP Dot Net Tutorial - DataGrid Control
ASP Dot Net Tutorial - Advance Practical Examples on DataGrid
ASP Dot Net Tutorial - Working with DataSets
ASP Dot Net Tutorial - Working with XML
ASP Dot Net Tutorial - Forms Based Authentication
ASP Dot Net Tutorial - Windows Based Authentication
     

 
Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > ASP.NET Tutorial > DataList Controls
 

ASP.NET Tutorial - DataList Controls

                                                                                                                 Page 1 of 3
 

The DataList Web server control displays rows of database information in customized format. These two controls play an important role in ASP.NET. They represent many common features.

The displayed data in customized format is defined in the item, alternating item, selected item, and edit item templates. Header, footer, and separator templates are also available to customize the overall appearance of the DataList. By including Button Web server controls in the template, list items can be connected to the code that allows users to switch between display, selection, and editing modes.

The DataGrid Web server control is a multi-column, data-bound grid. Columns can be made that displays and edit data. Multi-columns include Edit, Update, Cancel, Select buttons, Custom Buttons, and Template Columns. Therefore Template Columns can further be laid in Template-Editing Mode.

Controls performing support function

Before discussing these controls thoroughly, it is important to know how these controls support event bubbling, templates, and the DataKeys collection.

Event Bubbling

There are three standard controls in ASP.NET that support event bubbling:

  • the Repeater,
  • DataList, and
  • DataGrid controls.

These controls capture events in their child controls. When an event is raised in a child control, it "bubbles up" in the containing control, which can then execute a subroutine to handle the event.

It is seen that in Databinding section, a list of LinkButton controls can be displayed in a Repeater control. When a LinkButton control is clicked, a Click event is raised.Therefore instead of writing code to handle the Click event for each LinkButton individually, one subroutine with any Click event can be associated , that is raised in the Repeater control.

The Repeater, DataList, and DataGrid controls enable an association of a subroutine with an event bubbled up from a child control by specifying a value for the OnltemCommand property.

For example, in case of the Repeater control, a subrou­tine would be associated with the ItemCommand event like this:

Example:

<asp:Repeater

OnItemCommand="RepeaterItemCommand"

Runat="Server".>

<ItemTemplate>

<li>

<asp:LinkButton

Text='<%# Container.DataItem( "FirstName")%>’

Runat="Server" />

</ItemTemplate>

</asp:Repeater>

 

When any of the LinkButton controls rendered by the Repeater control are clicked the Click event occurs, the RepeaterItemCommand subroutine is executed to handle the event.

The DataList and DataGrid controls go a step further by allowing distinctions to be made between the events raised by their child controls.

The DataList and DataGrid controls support the following five events:

• ItemCommand

• UpdateCommand

• EditCommand

• DeleteCommand

• CancelCommand

When a child control is created in a DataList or DataGrid, the type of event to be raised in the containing control can be indicated by using the CommandName property.

For example, if you want to raise an UpdateCommand event, you would specify the CommandName property like this:

Example:

<asp:LinkButton

Text="Update Field!"

CommandName="update"

Runat="Server" />

 

Three controls of ASP.NET have CommandName property as LinkButton, Button, and ImageButton. They also have a CommandArgument property that enables to specify an optional argument that is passed when the control is clicked. So, an optional argument can be bubbled up by using an event like this:

Example:

<asp:LinkButton

Text=”Update Field!”

CommandName="update"

CommandArgument="12"

Runat="Server" />

 

Using Templates

Templates have been discussed earlier. The Repeater control supports several templates that enables to format the output of the control.

For example, you can use the ItemTemplate to format how the Repeater control renders each item that it displays.

The DataList and DataGrid controls also support templates. The DataList control supports the following templates:

Template Description
ItemTemplate Is an HTML elements and controls, which is rendered once for each row in the data source
AlternatingItemTemplate It is like the ItemTemplate element, but it is rendered for every other row in the DataList control. If this template is used a typically different look is created for it, such as a different background color than that of the ItemTemplate.
SelectedItemTemplate Is an element to render when the user selects an item in the DataList control. Typically it is used to visually mark the row using a background or font color. Displaying additional fields from the data source can expand the item
EditItemTemplate Is the layout of an item when it is in edits mode. This template typically contains editing controls, such as TextBox controls.
HeaderTemplate and FooterTemplate The text and controls are used to render at the beginning and end of the list.
SeparatorTemplate Is used to render between each item. A typical example might be a line (using an <HR> element).

       
 

 

 

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2006. All Rights Reserved.