DataList与Repeater嵌套绑定
<%@ 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嵌套绑定的更多相关文章
- 关于Repeater嵌套绑定的问题
前台代码: <div id="firstpane" class="menu_list"> <asp:Repeat ...
- Repeater嵌套绑定Repeater
前台Html代码 <asp:Repeater runat="server" ID="rpList" OnItemDataBound="rpLis ...
- 转:Repeater嵌套绑定Repeater以及内层调用外层数据
<table border=" style="margin-bottom: 5px" width="100%"> <asp:Repe ...
- Repeater嵌套绑定Repeater以及内层调用外层数据
aspx: <table border=" style="margin-bottom: 5px" width="100%"> <as ...
- DataList嵌套绑定例子
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DataList控件.asp ...
- Repeater 嵌套,子级Repeater获取 父级Repeater 中的值
第一种方法,子级Repeater中绑定父级的某个字段: <%# DataBinder.Eval((Container.NamingContainer.NamingContainer as Rep ...
- DataList和Repeater
DataList和Repeater是两个十分有用的控件,在新闻列表和图片展示的地方经常用到.在这里简单的把他们介绍一下. 1.DataList: 前端页面: <asp:DataList ID=& ...
- 关于Repeater中绑定的控件不触发ItemCommand事件
今天遇到 在repeater 中使用一个button,点击button然后跳转另外一个页面. html. <asp:Repeater ID="repeater" runat= ...
- Gridview、DataList、Repeater获取行索引号
Gridview.DataList.Repeater如何获取行索引号?很多情况下都会用得到,下面贴出代码,注意行索引号是从0开始,不是从1开始,如果要从1开始,请在代码里面+1就行了. Gridvie ...
随机推荐
- HDU 4405
http://acm.hdu.edu.cn/showproblem.php?pid=4405 题意:飞行棋,可以跳,从0走到n,问期望步数 题解:dp[i]表示从i走到n的期望,逆推,因为每次都要走一 ...
- invoke Javascript from C# code
http://justyouraveragegeek.com/blog/index.php/2010/03/winforms-with-a-webbrowsercontrol-fun-with-obj ...
- URL结尾反斜杠对SEO的影响(转)
开始纠结网站URL加不加反斜杠对SEO的影响,还有些人把这个反斜杠说的神乎其神,我擦,本人手贱百度了一下,果然“博大精深”,敬请参考! 从百度站长平台的外链分析里,我们可以看到,一些目录结构的URL, ...
- CentOS安装时小坑记录
在安装CentOS的时候,由于第一次安装小白,将VM虚拟机的内存设置为512M,导致进行安装的时候无法进入正常的画面安装模式,只能使用简版安装界面,可能对于很多小白不是很熟悉,特此记录,安装CentO ...
- yii2后台上传图片,前台也能显示 的方法
备注:::很low 高端人士 勿入 支持 吐槽 有你们的吐槽才有我的进步 还不会yii上传的 go out (哈哈,开玩笑)
- SQL根据现有表新建一张表
SQL根据现有表新建表,新建的这张表结构要跟现有表结构相同,但不要现有表里面的数据! 执行DML语句依据数据库类型而定: SQLITE -----复制表结构及数据到新表 CREATE TABLE TA ...
- boot/head.S
/* * linux/boot/head.S * * Copyright (C) 1991, 1992 Linus Torvalds */ /* * head.S contains the 32-bi ...
- HDU 4686 矩阵快速幂 Arc of Dream
由式子的性质发现都是线性的,考虑构造矩阵,先有式子,a[i] = ax * a[i-1] + ay; b[i] = bx*b[i-1] +by; a[i]*b[i] = ax*bx*a[i-1]*b[ ...
- leetcode 93 Restore IP Addresses ----- java
Given a string containing only digits, restore it by returning all possible valid IP address combina ...
- timus 1210 Kind Spirits(最短路)(动态规划)
Kind Spirits Time limit: 1.0 secondMemory limit: 64 MB Ivanushka the Fool lives at the planet of 0-l ...