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 ...
随机推荐
- 通过一段代码说明C#中rel与out的使用区别
using System; public partial class testref : System.Web.UI.Page { static void outTest(out int x, out ...
- bzoj4034 (树链剖分+线段树)
Problem T2 (bzoj4034 HAOI2015) 题目大意 给定一颗树,1为根节点,要求支持三种操作. 操作 1 :把某个节点 x 的点权增加 a . 操作 2 :把某个节点 x 为根的子 ...
- 清除浮动1-使用:after 伪元素
<!doctype html><html> <head> <meta charset="UTF-8"> <meta name= ...
- buildroot mysql
/******************************************************************** * buildroot mysql * 说明: * 这两天要 ...
- LINQ 按多个字段排序
多字段排序 添加到 LINQ 查询结果中的Take()扩展方法用于提取前 个结果: private static void Ordering() { var racers = (from r in F ...
- Notes of Linked Data concept and application - TODO
Motivation [反正债多了不愁,再开个方向.] Data plays a core role in most business systems, data storage and retrie ...
- Sprint第二个冲刺(第六天)
一.Sprint 计划会议: 因为这两天课程较多的原因,表面上进度可能可能没有太大的变化,其实组员们都有完善之前做的功能,正在做的功能也在抓紧时间完成.俗话说得好,慢工出细活 ,不能因为赶进度就随便做 ...
- C++之STL之string
/*C 语言中字符数组一般会采用char str[]来存放,但是显得会比较麻烦,C++在stl中加入了string类型,对字符串常用的功能进行了封装,操作起来比较方便*/#include<cst ...
- code::blocks的快捷键汇总
编辑部分: Ctrl + A:全选 Ctrl + C:复制 Ctrl + X: 剪切 Ctrl + V:粘贴 Ctrl + Z:撤销 Ctrl + S:保存 Ctrl + Y / Ctrl + S ...
- leetcode 132. Palindrome Partitioning II ----- java
Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...