嵌套Repeater实现页面导航
来源:互联网 发布:苏联艺术知乎 编辑:程序博客网 时间:2024/06/06 00:10
//前台代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<asp:Repeater id="rptCategories" runat="server"
onitemdatabound="rptCategories_ItemDataBound">
<HeaderTemplate>
<table 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, "ProduceName")%></a></td></tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</form>
</body>
</html>
//后台代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace WebApplicationUI
{
public partial class Repeater嵌套Repeater实现页面导航 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
bindRepeater();//绑定第一级父节点
}
{
public partial class Repeater嵌套Repeater实现页面导航 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
bindRepeater();//绑定第一级父节点
}
//绑定主Repeater
void bindRepeater()
{
BLL.ProductBll procduct=new BLL.ProductBll();
rptCategories.DataSource = procduct.getProduct();
rptCategories.DataBind();
}
rptCategories.DataBind();
}
//在绑定分类品名时,绑定分类下的产品
protected void rptCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
BLL.ProductBll products = new BLL.ProductBll();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rptProduct = (Repeater)e.Item.FindControl("rptProduct");
//找到分类Repeater关联的数据项
DataRowView row = (DataRowView)e.Item.DataItem;
//提取分类ID
int CategorieId = Convert.ToInt32(row["ID"]);
//根据分类ID查询该分类下的产品,并绑定产品Repeater
rptProduct.DataSource = products.getProduceById(CategorieId);
rptProduct.DataBind();
}
}
}
}
}
- 嵌套Repeater实现页面导航
- Repeater嵌套实现产品分类导航
- repeater控件嵌套实现系统/网站导航
- 在Repeater中嵌套使用Repeater,实现左侧导航菜单
- repeater控件介绍、 repeater嵌套的代码实现
- ASP.NET Repeater嵌套Repeater实现菜单加载
- Repeater控件嵌套效果的实现
- .net 双层repeater嵌套 实现树形结构
- Repeater嵌套
- 嵌套repeater
- repeater嵌套
- repeater嵌套
- Repeater嵌套
- repeater嵌套
- 嵌套repeater
- repeater嵌套
- Repeater嵌套
- 嵌套Repeater
- 我们要掌控什么——别人能做到的,我们未必能做到
- ls(1)命令的简单实现(一)
- Android Hal 分析
- XMPP协议实现原理介绍
- Linux下目录 /opt 和目录 /usr/local 的区别(网络搜集整理)
- 嵌套Repeater实现页面导航
- Android实现推送方式解决方案
- STL <set>练习
- Npoi导入导出到Excel
- 在项目中使用Npoi导出到Excel
- jquery学习的一点总结
- asp.net前后台方法和变量交互
- C语言运算符优先级和口诀
- 一个js日期格式化函数