DataList in ASP.Net

What is DataList in ASP.Net ? 

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. The following table describes those templates.


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.

<EditItemTemplate> Item: <asp:TextBox id="Text1" runat="server" Text='<%# ((DataRowView)Container.DataItem)["Item"] %>' /><br> <asp:LinkButton id="button1" runat="server" Text="Update" CommandName="update" /> <asp:LinkButton id="button2" runat="server" Text="Cancel" CommandName="cancel" /> </EditItemTemplate>

No comments:

Post a Comment