相思资源网 Design By www.200059.com
复制代码 代码如下:
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"] = "这是文章标题 " + 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>
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"] = "这是文章标题 " + 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>
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无Repeater怎么实现多行间隔显示分隔符的评论...