Repeater control for ASPX pages:
Copy Code code as follows:
<asp:repeater id= "Indextopmain" runat= "Server" >
<HeaderTemplate><!--Head-->
<ul>
</HeaderTemplate>
<ItemTemplate><!--Intermediate Cycle part-->
<li> <a href= "aritcledisplay.aspx?id=<% #Eval (" id ")%>" title= "<% #Eval (" title ")%>" target= "_ Blank "><% #Eval (" title "). ToString (). Length>30? Eval ("title"). ToString (). Substring (0,30) + "...": Eval ("title")%></a></li>
</ItemTemplate>
<FooterTemplate><!--Tail-->
</ul>
</FooterTemplate>
</asp:Repeater>
the binding of the CS file
Copy Code code as follows:
String indextopmainstr = "SELECT Top 9 Id,title to Table ORDER by id DESC";
SqlDataAdapter rst = new SqlDataAdapter (Indextopmainstr,conn);
Conn. Open (); The
DataSet Rdt = new DataSet ();
rst. Fill (RDT);
Indextopmain.datasource = rdt;//Data binding
Indextopmain.databind ();
Conn. Close ();