<%@ Page Language="C#" AutoEventWireup="true" CodeFile="home.aspx.cs" Inherits="home" %>

<body>
<form id="form1" runat="server">
<asp:DataList ID="monitorTypeList" runat="server" RepeatColumns="4"
onitemdatabound="monitorTypeList_ItemDataBound" RepeatDirection="Horizontal" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<table class="conBox" width="186" border="0" cellpadding="0" cellspacing="1" style="margin-right:10px;">
<tr>
<th><a href="<%#Eval("plugpath") %>"><%#Eval("monitor_type_name") %></a></th>
</tr>
<asp:Repeater ID="monitorConfigList" runat="server">
<ItemTemplate>
<tr>
<td><a href="<%#Eval("plugpath") %>?monitor_id=<%#Eval("monitor_id") %>"><%#Eval("monitor_name") %></a></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>

</ItemTemplate>
</asp:DataList>

</form>
</body>

home.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class home : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
myCheck.IsLoginNonReturn();
if (!IsPostBack)
{
Bind_monitorTypeList();
}
}

protected void Bind_monitorTypeList()
{
string sql = "select monitor_type_id,monitor_type_name from monitor_type";
DbConn conn = new DbConn();
DataSet ds = conn.DataSet(sql,"monitor_type");
monitorTypeList.DataSource = ds.Tables[0];
monitorTypeList.DataBind();
ds.Dispose();
conn.Close();
}

protected void monitorTypeList_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string monitor_type_id = ((DataRowView)e.Item.DataItem).Row["monitor_type_id"].ToString();
Repeater monitorConfigList = (Repeater)e.Item.FindControl("monitorConfigList");
if (monitorConfigList != null)
{
string sql = "select monitor_id,nonitor_name,plugpath from monitor where monitor_type_id=" + monitor_type_id;
DbConn conn = new DbConn();
DataSet ds = conn.DataSet(sql, "monitor");
monitorConfigList.DataSource = ds.Tables[0];
monitorConfigList.DataBind();
ds.Dispose();
conn.Close();
}
}
}
}

转自:http://www.cnblogs.com/Fooo/archive/2009/06/14/1503234.html

DataList与Repeater嵌套绑定的更多相关文章

  1. 关于Repeater嵌套绑定的问题

    前台代码: <div id="firstpane" class="menu_list">                <asp:Repeat ...

  2. Repeater嵌套绑定Repeater

    前台Html代码 <asp:Repeater runat="server" ID="rpList" OnItemDataBound="rpLis ...

  3. 转:Repeater嵌套绑定Repeater以及内层调用外层数据

    <table border=" style="margin-bottom: 5px" width="100%"> <asp:Repe ...

  4. Repeater嵌套绑定Repeater以及内层调用外层数据

    aspx: <table border=" style="margin-bottom: 5px" width="100%"> <as ...

  5. DataList嵌套绑定例子

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataList控件.asp ...

  6. Repeater 嵌套,子级Repeater获取 父级Repeater 中的值

    第一种方法,子级Repeater中绑定父级的某个字段: <%# DataBinder.Eval((Container.NamingContainer.NamingContainer as Rep ...

  7. DataList和Repeater

    DataList和Repeater是两个十分有用的控件,在新闻列表和图片展示的地方经常用到.在这里简单的把他们介绍一下. 1.DataList: 前端页面: <asp:DataList ID=& ...

  8. 关于Repeater中绑定的控件不触发ItemCommand事件

    今天遇到 在repeater 中使用一个button,点击button然后跳转另外一个页面. html. <asp:Repeater ID="repeater" runat= ...

  9. Gridview、DataList、Repeater获取行索引号

    Gridview.DataList.Repeater如何获取行索引号?很多情况下都会用得到,下面贴出代码,注意行索引号是从0开始,不是从1开始,如果要从1开始,请在代码里面+1就行了. Gridvie ...

随机推荐

  1. 用Inno Setup来解决.NetFramework安装问题

    用Inno Setup来解决.NetFramework安装问题 2010-03-01 09:59:26 标签:.Net Framework Setup 休闲 Inno 原创作品,允许转载,转载时请务必 ...

  2. yii表单

    yii  的dropdownlist,用yii的session可以记下选中的状态 $form = $this->beginWidget('CActiveForm',array('action'= ...

  3. Java-->发牌流程修改版

    --> 这一次要封装得狠一点... package com.xm.ddz; // 每一张牌的属性 public class Card { private String flowerColor; ...

  4. div排序 根据《input》

    jquery代码如下$(function(){//alert($("input").length); var arr=Array(); $("input").e ...

  5. Android加载网络图片的工具类

    ImageView加载网络的图片 HttpUtil.java package com.eiice.httpuimagetils; import java.io.ByteArrayOutputStrea ...

  6. hbase(ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet)

    今天启动clouder manager集群时候hbase list出现 (ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException ...

  7. POJ2112 Optimal Milking (网络流)(Dinic)

                                             Optimal Milking Time Limit: 2000MS   Memory Limit: 30000K T ...

  8. 二叉树遍历 空间复杂度为O(1)

    http://blog.csdn.net/mxw976235955/article/details/39829973 http://www.tuicool.com/articles/zA7NJbj / ...

  9. linux环境进程的停止

    使用 #ps auxf|grep 你想要获取的进程,如下,我想要获得的是nginx的进程号 图中黄色的便是进程号, 在此我们想kill掉主进程就要把后面有master字样的进程号kill掉 命令如下 ...

  10. ExtJS控件样式修改及美化

    Extjs项目对富客户端开发提供了强有力的支持,甚至改变了前端的开发方式,使得开发变得更加趋向于“面向组件”.对界面的美化而言,也是根本性的改变.普通的网页美工面对extjs项目根本无法下手,需要脚本 ...