Recently in the project need to use ASP. Repeater control pagination display data, a page showing 12, found on the Internet instance, but there are typesetting problems, modified the issued, share to everyone
. aspx
<asp:repeater id="Repeater1"runat="Server"Onitemdatabound="Repeater1_itemdatabound"> <HeaderTemplate> <table style="width:100%; border:0; text-align:center ;"><tr> </HeaderTemplate> <ItemTemplate> <div> & Lt;td> 'images/'+<%# Eval ("Author")%>+'. PNG'alt='<%# Eval ("Author")%>'style="width:150px; height:150px; margin-bottom:2px; margin-left:2px; margin-right:2px ; margin-top:2px;"/><br/> <a href='minjiaxiangxi.aspx? name=<%# Eval ("ID")%>'><%# Eval ("Author")%></a></td> </div> </ItemTemplate> <FooterTemplate> </t R></table> </FooterTemplate> </asp:Repeater>
To use the Repeater control's ItemDataBound event, double-click on it, then add the following code
protected inti =0;//Global Variables protected voidRepeater1_itemdatabound (Objectsender, RepeaterItemEventArgs e) { if(i%4==0) {E.item.controls.add (NewLiteralControl ("</tr><tr>")); } I++;//don't forget that.//This method displays 4 data lines in a row}
This method refers to the following blog
Http://blog.csdn.net/redfox521/article/details/2200101
About multi-line display of repeater