DataList and Repeater are two very useful controls that are often used in news lists and image presentations. Here we will briefly introduce them.
1. DataList:
Front-end page:
<Asp: DataList ID = "PicList" runat = "server" RepeatColumns = "3" Width = "90%" RepeatDirection = "Horizontal">
<ItemStyle BorderWidth = "0" BorderStyle = "none" Width = "200" HorizontalAlign = "center"/>
<ItemTemplate>
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "100%">
<Tr>
<Td height = "110px">
'width = "174" height = "130" alt = "" style = "cursor: hand; "/>
</Td>
</Tr>
<Tr>
<Td align = "center" height = "40px">
<Asp: Label ID = "Content" runat = "server" Width = "100%" Text = '<% # Eval ("IMGms") %>'/> </td>
</Tr>
</Table>
</ItemTemplate>
</Asp: DataList>
Attribute description: RepeatColumns: number of duplicate entries in the horizontal or scholarly manner;
RepeatDirection: Repetition direction.
Background code:
This. PicList. DataSource = ds;
This. PicList. DataBind ();
2. Repeater: easier to use,
<Asp: Repeater ID = "Repeater3" runat = "server">
<ItemTemplate>
<Div align = "left" class = "divp1">
& nbsp; <a href = 'talent. aspx? Nurl = <% # Eval ("MenuURL") %> 'target = "_ blank"> <strong> <% # Eval ("MenuName ") %> </strong> </a>
</Div>
</ItemTemplate>
</Asp: Repeater>
The background is similar to datalist.