Asp. A detailed explanation of the Net:repeater control

Source: Internet
Author: User
Tags eval mdb database
Asp.net| Control | After studying the DataGrid control and the DataList control, we know that the DataGrid control automatically generates htmltable tags for the data output format, as is the DataList control, which generates data control tables based on the contents of the data. The Repeater control is a templated list of data bindings, and the Repeater control is "no appearance", that is, it does not have any built-in layout or style, and does not produce any data control tables to control the display of the data. Therefore, we must explicitly declare all HTML layout tags, formatting marks, and style tags in the template of the control.

In the first section, we also said that the repeater control is a lightweight data-bound control that generally uses it to output relatively simple data, and, below, we use this control to make a simple walls. In this message board, we make full use of the control of the repeater controls, data display, data paging, embedded control response events and so on.

First, create a new Guestbookdata.mdb database with Access2003, including a datasheet guestmessage, and the Data table field properties as shown in Figure 9.16.


Figure 9.16 guestmessage data table field Properties

A full-featured message board should include three main contents:
(1), Message browsing
(2), post a message
(3), message Management (reply, delete. Some also require audit function)

Let's take a detailed description of our example based on these three features.

Add a WebForm form to the Datacon Web project, named Repeater_sample.aspx, adding a Repeater control, id= "Repeater1"; three panel controls, the IDs of three panel controls are " Login "," Reply "and" write ".

First we look at the HTML layout code for the "Message browsing" feature. In the "Message Browsing" section, we apply the Repeater control, which has property columns, binding settings, and embedded control properties as follows, with attention to the use of bound data:

<table id= "Table2" style= "WIDTH:384PX; TR: "
cellspacing= "0" cellpadding= "0" width= "384"
Align= "left" border= "0" >
<TBODY>
<tr bordercolor= "#009900" >
<td><asp:linkbutton id= "Say" runat= "Server" > I have to say two words </asp:linkbutton></td>
</TR>
<TR>
<TD>
<asp:repeater id= "Repeater1" runat= "Server" >
<ItemTemplate>
<table width= "1" border= "
cellpadding= "0" cellspacing= "0"
Bordercolor= "#009966" style= "font-size:12px" >
<tr>
&LT;TD width= "height=" >
Nickname: <%# DataBinder.Eval (Container.DataItem, "name")%></td>
&LT;TD width= ">"
This is <b><%# DataBinder.Eval (Container.DataItem, "name")%>
</b><%# DataBinder.Eval (Container.DataItem, "sex")%> in [<%# DataBinder.Eval, Container.DataItem, " Senddate ").%&gt message </td>
</tr>
<tr>
<td><%# "</td >
<td><%# DataBinder.Eval (Container.DataItem, "content")%></td>
</tr>
<tr>
<td><%# "
<%# DataBinder.Eval (Container.DataItem, "IP")%>
</td><td>
<%# "<a href=mailto:" & DataBinder.Eval (Container.DataItem, "email") & "> email to him </a>"%>
<asp:linkbutton runat=server CommandName = "del" commandargument= ' <%# DataBinder.Eval (Container.DataItem, "ID") %> ' id= "Linkbutton1" name= "Linkbutton1" > Delete message </asp:LinkButton>

<asp:linkbutton runat=server CommandName = "Reply" commandargument= ' <%# DataBinder.Eval (Container.DataItem, "ID ")%> ' id=" Linkbutton2 "name=" Linkbutton1 "> Reply message </asp:LinkButton>
</tr>
</table>
</ItemTemplate>
<SeparatorTemplate>
<table width= "border=" 0 "cellpadding=" 0 "cellspacing=" 0 ">
<tr>
&LT;TD width= "background=" "Image/bg01.gif" ></td>
</tr>
</table>
</SeparatorTemplate>
</asp:repeater></TD>
</TR>
<tr bordercolor= "#009900" >
&LT;TD class= "Style2" style= "font-size:12px" bordercolor= "#009900" align= "right" colspan= "2" ><asp:label id= " Pagesinfor "runat=" Server "font-size=" X-small "></asp:label>/<asp:linkbutton id=" PrevPage "runat=" Server "font-size=" x-small >[previous page]</asp:linkbutton>
<asp:linkbutton id= "nextpage" runat= "Server" font-size= "X-small" >[next page] </asp:linkbutton> jump to page <asp: DropDownList id= "Pageslist" runat= "Server" autopostback= "True" ></asp:dropdownlist> page
</TD>
</TBODY>
</TABLE>

[1] [2] [3] [4] Next page



Related Article

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.