分类页面:repeater控件的应用
来源:互联网 发布:淘宝店铺规划 编辑:程序博客网 时间:2024/05/16 12:42
前台页面
<ul>
<asp:Repeater runat="server" ID="rptList" OnItemDataBound="rptCategory_ItemDataBound">
<ItemTemplate>
<li>
<a href='ArticleList.aspx?id=<%# Eval("Id") %>'><img src='<%# Eval("ImageUrl") %>' /></a>
<div>
<h4><a href='ArticleList.aspx?id=<%# Eval("Id") %>'><%# Eval("Title") %></a></h4>
<p><asp:Literal ID="ltrDes" runat="server" />...</p>
</div>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
后台页面
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bjxmh.Jingci;
using System.Text;
public partial class tools_food_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) {
Category _category = new Category();
rptList.DataSource = _category.GetCategoryInfoes();
rptList.DataBind();
}
protected void rptCategory_ItemDataBound(object sender, RepeaterItemEventArgs e) {
if (e.Item.DataItem != null) {
CategoryInfo categoryInfo = (CategoryInfo)e.Item.DataItem;
Food _food = new Food();
var infoes = _food.GetContentInfoByCategoryId(categoryInfo.Id);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < Math.Min(infoes.Count, 3); i++) {
sb.AppendFormat("<a href='Article.aspx?id={1}'>{0}</a> ", infoes[i].Title, infoes[i].Id);
}
((Literal)e.Item.FindControl("ltrDes")).Text = sb.ToString();
}
}
}
repeater控件可以随意调用数据
- 分类页面:repeater控件的应用
- Repeater控件的应用
- Repeater控件的应用
- Repeater控件的应用
- 浅析Repeater的子控件的应用
- 浅析Repeater的子控件的应用
- 前台应用----------Repeater控件
- 前台应用----------嵌套repeater控件
- asp:Repeater控件的应用,System.Data.DataRowView
- Repeater控件的四两拨千斤
- 嵌套的Repeater 控件
- Repeater控件的使用
- Repeater控件的使用
- Repeater控件的使用
- Repeater控件的模板
- Repeater控件的使用
- Repeater控件的使用
- Repeater控件的使用
- 【C++Primer学习笔记】第3章 标准库类型
- 取得屏幕大小
- Flex 利用bitmap和bitmapData改变图片为黑白画
- ADC 驱动移植
- 区域性问题导致多语言软件运行出错
- 分类页面:repeater控件的应用
- 图像解析库使用范例
- 堆和栈的区别(转过无数次的文章)
- android平台调用vlc播放器的例子
- ini 文件操作
- 丢失grub的安装和修复 mbr 以及制作U盘安装grub
- android 常用对话框 ---转载
- Facestagram: 合体Instagram五个新特性YY
- PAFF 和MBAFF