The DataList control is a lot like the Repeater control insofar as binding data in concerned. However, using a DataList control is when we need a single-column list. For Example, suppose we’re setting up a networking party with donors to a political campaign. Each donor will wear a nametag with his or her e-mail address so that the participants can easily exchange e-mail contact. The format for each nametag should look like the following:
Donor’s Name: Mary Smith
Email: ms@msmith.com
Now everyone can see that the other people are fellow donors and can see their e-mail address for future contact.
We will find using the DataList control very simple compared with the Repeater in conjunction with HTML tables. Because we only have a single column, all of our formatting can be done without worry about multiple columns or any table tags. For example, we can format the text within <ItemTemplate> container pretty much as we would HTML:
<ItemTemplate>
<strong>Field Description:</strong>
<%# Eval(“FieldName”) %>
</ItemTemplate>
Stacked up in a single column, each record needs to be separated. Using the <SeparatorTemplate>, we can make sure that the viewer can tell where one record begins and the previous one ends. Depending on what we’re doing with our data, our separator can just add vertical space or provide instructions.
Tuesday, February 16, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment