Copy codeThe Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
If (! Page. IsPostBack)
{
RptList. DataSource = GetTable ();
RptList. DataBind ();
}
}
Protected void rptList_ItemDataBound (object sender, RepeaterItemEventArgs e)
{
If (e. Item. ItemType = ListItemType. AlternatingItem | e. Item. ItemType = ListItemType. Item)
{
DataRowView drv = (DataRowView) e. Item. DataItem;
Literal ltlTitle = (Literal) e. Item. FindControl ("ltlTitle ");
LtlTitle. Text = drv. Row ["title"]. ToString ();
If (e. Item. ItemIndex + 1) % 5 = 0 & (e. Item. ItemIndex + 1) <15)
{
System. Web. UI. LiteralControl ul = new LiteralControl ("
");
E. Item. Controls. Add (ul );
}
}
}
DataTable GetTable ()
{
DataTable dt = new DataTable ();
Dt. Columns. Add ("title", typeof (string ));
For (int I = 1; I <= 15; I ++)
{
DataRow row = dt. NewRow ();
Row ["title"] = "this is the title of the article" + I + "";
Dt. Rows. Add (row );
}
Return dt}
</CODE> form id = "form1" runat = "server">
</CODE> div>
</CODE> asp: Repeater ID = "rptList" runat = "server"
Onitemdatabound = "rptList_ItemDataBound">
</CODE> HeaderTemplate>
</CODE> ul>
</CODE> HeaderTemplate>
</CODE> ItemTemplate>
</CODE> li>
</CODE> asp: Literal ID = "ltlTitle" runat = "server"> </CODE> asp: Literal> </CODE> li>
</CODE> ItemTemplate>
</CODE> FooterTemplate>
</CODE> ul> </CODE> FooterTemplate>
</CODE> asp: Repea </CODE> form>