Datalist introduction. It is helpful to pay more attention to the item layout!

Source: Internet
Author: User

Msdn datalist introduction. It is useful to pay more attention to the item layout! Control layout Template

InDatalistControl, use the template to define the layout of information.DatalistControls Support the following templates:

Template Description
Itemtemplate Displays HTML elements and controls for each row in the data source.
Alternatingitemtemplate AndItemtemplateThe element is similar,DatalistThe rows in the control are rendered once every row. If you use this template, you usually create different appearances for it, suchItemtemplateDifferent Background colors.
Selecteditemtemplate When you selectDatalistThe element that is rendered when the item in the control is used. Typically, the row is marked visually with the background color or font color. You can expand this item by displaying other fields in the data source.
Edititemtemplate The layout when the item is in editing mode. This template usually contains editing controls, suchTextboxControl.
HeadertemplateAndFootertemplate Text and controls displayed at the beginning and end of the list.
Separatortemplate The elements presented between each item. A typical example is a row (using the <HR> element ).
Item Layout

You can use a template to specify the layout of controls and text in individual items, and specify how these items should be arranged relative to other items.DatalistControls provide the following options:

Option Description
Stream and tableRepeatlayoutSet propertyFlowOrTable In the stream layout, the list items are displayed in the row in the style of the word processing document.

In the table layout, items are displayed in the HTML table, which makes it easier to specify the appearance of items because it allows you to set table cell attributes, such as grid lines. For more information, see specify a stream or table style in the datalist Web Server Control.

Vertical and horizontal sortingRepeatdirectionSet propertyVerticalOrHorizontal By default, it is displayed in a single vertical columnDatalistControl. However, you can specify that the control contains multiple columns. In this case, you can further specify whether these items are vertically ordered (similar to the report column) or horizontally arranged (similar to the days in the calendar ). For more information, see specify a horizontal or vertical layout in the datalist Web Server Control.
Number of ColumnsRepeatcolumns No matterDatalistThe items in the control are vertical or horizontal, you can specify how many columns the list will have. This allows you to control the rendering width of web pages, which can avoid horizontal scrolling.
Event

DatalistControls Support several events. One of these eventsItemcreatedAn event provides a way to customize the creation process during running.ItemdataboundEvent customization is also providedDatalistControl capabilities, but can only be provided after the data can be used for inspection. For example, if you are usingDatalistControls display the to-do list, you can use red text to display expired items, black text to show completed items, and green text to show other tasks. Both events can be used to override the format settings defined by the template.

Other events are triggered when the buttons in the Response List are clicked. They are designed to help you respondDatalistThe most common functions of a widget. Four events of this type are supported:

    • Editcommand
    • Deletecommand
    • Updatecommand
    • Cancelcommand

When a user clicks a button, the event will bubble to the container of the button:DatalistControl. The exact event triggered by the button depends onCommandnameAttribute. For example, ifCommandnameThe property isEditThis button causesEditcommandEvent. IfCommandnameThe property isDeleteThis button causesDeletecommandEvents.

DatalistControls are also supportedItemcommandEvent. This event is triggered when you click a button that does not have a predefined command (such as "edit" or "delete. ClickCommandnameSet the property to a required value, and thenItemcommandEvent ProcessingProgramTest the event and use it for custom functions. (For example, you can use this method when selecting an item, as described in allowing users to select an item in the datalist Web Server Control .)

RelatedDatalistFor a complete list of events supported by the control, see datalist events. For more information about web form events, see ASP. NET Server Control event model.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.