----------------------------------------------------------- New Message on MumbaiUserGroup
----------------------------------------------------------- From: Swapnil_B1 Message 1 in Discussion DataList Control The DataList control displays data items in a repeating list, and optionally supports selecting and editing the items. The content and layout of list items in DataList is defined using templates. At a minimum, every DataList must define an ItemTemplate; however, several optional templates can be used to customize the appearance of the list. Various Templates Supported by Data List ItemTemplate - Defines the content and layout of items within the list. Required. AlternatingItemTemplate - If defined, determines the content and layout of alternating items. If not defined, ItemTemplate is used. SeparatorTemplate (new) - If defined, is rendered between items (and alternating items). If not defined, a separator is not rendered. SelectedItemTemplate - If defined, determines the content and layout of the selected item. If not defined, ItemTemplate (AlternatingItemTemplate) is used. EditItemTemplate - If defined, determines the content and layout of the item being edited. If not defined, ItemTemplate (AlternatingItemTemplate, SelectedItemTemplate) is used. HeaderTemplate - If defined, determines the content and layout of the list header. If not defined, the header is not rendered. FooterTemplate - If defined, determines the content and layout of the list footer. If not defined, the footer is not rendered. Templates define the HTML elements and controls that should be displayed for an item, as well as the layout of these elements. Style formatting -- font, color, and border attributes -- is set via styles. Each template has its own style property. For example, styles for the EditItemTemplate are set through the EditItemStyle property. A third set of properties affect the overall rendering of DataList. By default, DataList items render within a table as a single vertical column. Setting the RepeatLayout property to Flow removes the HTML table structure from the rendering of the list. DataList supports directional rendering through the RepeatDirection property, meaning it can render its items horizontally or vertically. Since page width is the dimension that the developer must control in Web user interface, DataList permits the developer to control the number of "columns" that are rendered (RepeatColumns), regardless of whether the items are rendered horizontally or vertically. Selecting Items in DataList You can customize the content and appearance of the selected item through the SelectedItemTemplate property. The SelectedItemTemplate is controlled by the SelectedIndex property. By default the value of SelectedIndex is -1, meaning none of the items in the list is selected. When SelectedIndex is set to a particular item, that item is displayed using the SelectedItemTemplate. Editing DataList Items The DataList control supports in-place editing of the data in an item through its EditItemTemplate property. The EditItemTemplate defines the content and appearance of the item when it is being edited. The EditItemTemplate interacts with another property: EditItemIndex. By default, the value of EditItemIndex is -1, meaning none of the items in the list is being edited. When EditItemIndex is set to a particular item, that item is displayed using the EditItemTemplate. The DataList also supplies three events that can be used to support editing. EditCommand is thrown when an "edit" command button control is clicked within the list's ItemTemplate. It's up to you to handle this event in your code. The EditItemTemplate typically contains "update" and "cancel" command buttons. These buttons cause the UpdateCommand and CancelCommand events to be thrown, respectively. It's up to you to handle these events in your code. The typical logic for "cancel" sets EditItemIndex to -1, and then rebinds the data to the DataList. The typical logic for "update" updates the data source, sets EditItemIndex to -1, and then rebinds the data to the DataList. DataList renders additional elements, like table rows and cells and spans containing style attributes, outside of the template definition to enable layout formatting. For example, DataList supports RepeatColumns and RepeatDirection properties that specify whether data should be rendered in multiple columns, and in which direction (vertical or horizontal) the data items should be rendered. Events in DataList You can fire a command from inside a DataList template that is passed to an event handler wired to the DataList itself. For example, a LinkButton inside the ItemTemplate might fire a Select command. By setting the OnSelectedIndexChanged property of the DataList, you can call an event handler in response to this command. Note that while the DataList recognizes a few special commands such as Select and Edit/Update/Cancel, the command string fired inside a template can be any arbitrary string. For all commands, the DataList's OnItemCommand is fired. Note that unlike GridView, DataList does not support automatically updating and deleting using a data source control, so you need to write code to handle the edit, update, and delete commands yourself (using the same model as was supported in ASP.NET v1.x). Swapnil (Swaps) http://swapsnet.spaces.live.com/ ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
