嵌套repeater

来源:互联网 发布:photoshop cs5 mac 编辑:程序博客网 时间:2024/05/21 04:20
using System;using System.Collections;using System.Configuration;using System.Data;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;public partial class IndexJob : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {        if (!Page.IsPostBack)        {            RepTop.DataSource = ZpInfoBLL.GetTopList("10");            RepTop.DataBind();            List();        }    }    protected void List()    {        RepList.DataSource = ParamsBLL.GetLIst("PositionTitle");        RepList.DataBind();    }    protected void RepList_ItemDataBound(object sender, RepeaterItemEventArgs e)    {        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)        {            Repeater rp = (Repeater)e.Item.FindControl("RepList1");//RepList1是 嵌套的repeater            DataRowView drv = (DataRowView)e.Item.DataItem;            //取得ID            int id = Convert.ToInt32(((DataRowView)e.Item.DataItem).Row["id"]);            //根据获得ID读取数据            rp.DataSource = ParamsBLL.GetLIst2(id.ToString());            rp.DataBind();        }    }}


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<%@ Page Language="C#" MasterPageFile="Index.master" AutoEventWireup="true" CodeFile="IndexJob.aspx.cs" Inherits="IndexJob" Title="无标题页" %><%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">    <link href="css/cssIndex.css" rel="stylesheet" type="text/css" /><link href="css/xx.css" rel="stylesheet" type="text/css" /></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><div class="news"><h3>最新招聘信息</h3><div class="two"><ul><li class="ming">招聘职位</li><li class="ming">企业名称</li><li class="ming">工作地点</li><li class="ming" style="width:80px;">月薪</li><li class="ming" style="width:80px;">发布时间</li></ul></div><asp:Repeater ID="RepTop" runat="server"><ItemTemplate><a href="IndexMore.aspx?id=<%#Eval("id")%>"><div class="two"><ul><li><%#Eval("paramText1")%></li><li><%#getStr.getString(Eval("CompanyName").ToString(),15)%></li><li><%#getStr.getString(Eval("Address").ToString(),15)%></li><li style="width:80px;"><%#Eval("BasicSalary")%></li><li style="width:80px;"><%# DateTime.Parse(Eval("PostDate").ToString()).ToShortDateString()%></li></ul></div></a></ItemTemplate></asp:Repeater><div style="clear:both"></div></div>    <div class="main"><h3>招聘信息分类</h3><div class="types"><ul>    <asp:Repeater ID="RepList" runat="server" onitemdatabound="RepList_ItemDataBound">      <ItemTemplate>            <li><h2><a href="IndexList.aspx?id=<%#Eval("id") %>&Pid=0"><%#Eval("ParamText")%></a></h2>                <p>             <asp:Repeater ID="RepList1" runat="server">             <ItemTemplate>                <a href="IndexList.aspx?id=<%#Eval("id") %>&Pid=1"><%#Eval("ParamText")%></a><cite>|</cite>             </ItemTemplate>             </asp:Repeater>                </p>                </li></ItemTemplate></asp:Repeater>                </ul></div></div><div style="clear:both"></div></asp:Content>