zoukankan
html css js c++ java
asp.net Repeater中嵌套使用Repeater
在一般的网站中浏览类别的用户控件通常都位于大多数 ASP.NET 页的左边,它使用户能够按类别快速的查找产品。最近遇到一个客户,因为在他网站上展示的产品并不多,所以要求在原有类别浏览的基础上将产品也加进去。一来更方便,二来加长了左部导航栏的长度使页面更协调。原有的分类导航栏是由Repeater实现的,现在需要在每一个分类下加入该类的商品信息,于是我想到了在原有Repeater中嵌套Repeater。实现界面如下:
前台页面部分:
<
asp:Repeater id
=
"
rptCategories
"
runat
=
"
server
"
>
<
HeaderTemplate
>
<
table width
=
"
100%
"
border
=
"
0
"
cellspacing
=
"
0
"
cellpadding
=
"
0
"
>
</
HeaderTemplate
>
<
ItemTemplate
>
<!--
分类名称
-->
<
tr
><
th
><%
# DataBinder.Eval(Container.DataItem,
"
TypeName
"
)
%></
th
></
tr
>
<!--
分类下的产品
-->
<
asp:Repeater id
=
"
rptProduct
"
runat
=
"
server
"
>
<
ItemTemplate
>
<
tr
><
td
><
a href
=
'
ProductInfo.aspx?Id=<%# DataBinder.Eval(Container.DataItem, "ID") %>
'
><%
# DataBinder.Eval(Container.DataItem,
"
ProductName
"
)
%></
a
></
td
></
tr
>
</
ItemTemplate
>
</
asp:Repeater
>
</
ItemTemplate
>
<
FooterTemplate
>
</
table
>
</
FooterTemplate
>
</
asp:Repeater
>
后台代码部分(部分代码):
//
在绑定分类品名时,绑定分类下的产品
private
void
rptCategories_ItemDataBound(
object
sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
BLL.Products products
=
new
BLL.Products();
if
(e.Item.ItemType
==
ListItemType.Item
||
e.Item.ItemType
==
ListItemType.AlternatingItem)
{
Repeater rptProduct
=
(Repeater) e.Item.FindControl(
"
rptProduct
"
);
//
找到分类Repeater关联的数据项
DataRowView rowv
=
(DataRowView)e.Item.DataItem;
//
提取分类ID
int
CategorieId
=
Convert.ToInt32(rowv[
"
ID
"
]);
//
根据分类ID查询该分类下的产品,并绑定产品Repeater
rptProduct.DataSource
=
products.GetProductsByCategorieId(CategorieId);
rptProduct.DataBind();
}
}
查看全文
相关阅读:
让Python支持中文注释
【转】python入门指引
【转】布同:如何循序渐进学习Python语言
在nagios中监控windows主机系统地址的状态
大神
music
20·15-01-21
2015-01-20
2015-01-19
2015-01-18
原文地址:https://www.cnblogs.com/wucf2004/p/770111.html
最新文章
微信小程序开发中遇到的那些坑(1)
Linux的 ls 和 ll 的使用发放、基本区别
Linux 开机网络无法自动连接配置、网络开机自动连接
Linux 7个运行级别(0:关机,停机模式、1:单用户模式、2:多用户模式、3:完整的多用户文本模式、4:系统未使用,保留一般不用、5:图形化模式、6:重启模式)、重置root密码方法
Linux下查看文件大小、文件占磁盘大小等详解(du 和df )使用命令
修改Linux主机名称
Oracle 关于身份证校验规则详细说明(附有代码复制可执行)
oracle定时备份
oracle数据库误删恢复方法
linux 字体查询、添加字体方式
热门文章
Linux 系统中处理磁盘已满但找不到对应的大文件的问题 lsof | grep deleted
Oracle 导出CSV、导出大数据
Oracle 使用技巧(一)
Linux 的 history 命令使用大全
【转】Linux从入门到精通——运维工程师成长路线图——CTO马哥Linux视频教学
【转】 要做linux运维工程师的朋友,必须要掌握以下几个工具才行
【转】Linux shell笔记
【转】Linux上vi(vim)编辑器使用教程
无法远程连接SQLSERVER2000的解决方法
Python类的__getitem__和__setitem__特殊方法
Copyright © 2011-2022 走看看