1.前台代码:

<asp:Repeater ID="OrderList" runat="server"
onitemdatabound="OrderList_ItemDataBound">
<ItemTemplate>
<div class="item">
<table class="table" style=" border:1px solid #DDCCCC;; border-right:none;" cellspacing="" cellpadding="">
<tr><td rowspan="" colspan=""><h1>益农乐游农品清单</h1></td><td>发货单号:</td><td colspan=""></td></tr>
<tr><td>时间:</td><td colspan=""></td></tr>
<tr><td >订单号:</td>
<td colspan=""><%#Eval("orderCode")%></td>
<td>下单时间:</td>
<td colspan=""><%#Eval("ordertime")%></td></tr>
<tr><td >收货人:</td><td><%#Eval("consignee")%></td><td>地址:</td><td colspan="" style=" text-align:left;"><%#Eval("address")%></td></tr>
<tr><td >电话:</td><td colspan="" style=" text-align:left"><%#Eval("mobile")%></td></tr>
<tr><td colspan="">&nbsp;</td></tr>
<tr><td>序号</td><td colspan="">农品描述</td><td>单价</td><td>数量</td><td>金额</td></tr>
<asp:Repeater runat="server" ID="detailOrder">
<ItemTemplate>
<tr><td><%#Eval("rowID")%></td>
<td colspan="" class="tr" style=" text-align:left"><%#Eval("Name")%></td>
<td><%#Eval("UnitPrice")%></td>
<td><%#Eval("Count")%></td><td>
<%#Eval("TotalPrice")%></td></tr>
</ItemTemplate>
</asp:Repeater>
<tr><td class="dd">配送费:</td><td><%#Eval("express")%></td><td class="dd">促销折扣:</td><td colspan="" class="dd"><%#Eval("perferPrice")%></td><td class="dd">订单金额:</td><td><%#Eval("amount")%></td><td class="dd" style=" ">游游卡支付:</td><td><%#Eval("ka")%></td></tr>
<tr><td>已付款:</td><td><%#Eval("resultAmount")%></td><td>应付款:</td><td colspan="" style="text-align:left;"><%#Eval("resultAmount")%></td></tr>
</table>
</div>
</ItemTemplate> </asp:Repeater>

2.后台代码:

 protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
string ids =Request.Params["ids"];
string[] array = ids.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
string newids = string.Join(",", array);
InitData(newids);
}
}
public void InitData(string newids)
{
var _list = odpdbasicBLL.GetModelList(" ID in (" + newids + ")").Select(c => new OrderNode
{
orderID=c.ID,
orderCode = c.OrderCoder,
ordertime = c.Created.ToString(),
consignee = c.Consignee,
mobile = c.Mobile,
address =c.Address +"(" +c.PostCode+")",
amount = string.Format("{0:.00}",c.Amount), //金额
perferPrice ="未打折" ,//打折
express =c.Express==?"0.00":string.Format("{0:.00}",c.Express),
resultAmount =string.Format("{0:.00}",Convert.ToDouble(c.Amount) -Convert.ToDouble(c.SubPrice) + Convert.ToDouble(c.Express)),
yingAmount=c.Status==?string.Format("{0:.00}",Convert.ToDouble(c.Amount) -Convert.ToDouble(c.SubPrice) + Convert.ToDouble(c.Express)):"0.00",
ka="0.00"
}).ToList();
OrderList.DataSource = _list;
OrderList.DataBind();
} protected void OrderList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("detailOrder") as Repeater;//找到里层的repeater对象
OrderNode rowv = (OrderNode)e.Item.DataItem;//找到分类Repeater关联的数据项
int ID= rowv.orderID; //获取填充子类的orderID
int i = ;
var _list = odpddetailBLL.GetModelList("OrderID=" + ID).Select(c => new
{
rowID=i++,
Name=c.Name+"("+c.ProNameStr+")",
UnitPrice=c.UnitPrice,
TotalPrice=c.TotalPrice,
Count=c.Count, }).ToList();
rep.DataSource =_list;
rep.DataBind();
}
}

3.说明:

因为数据是model类型的所以在

 OrderNode rowv = (OrderNode)e.Item.DataItem;//找到分类Repeater关联的数据项 

是转成model类型,若是数据是table类型,那么在此就应该是

 DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 

Repeater控件的嵌套使用的更多相关文章

  1. Repeater 控件的嵌套使用

      Repeater 控件的嵌套使用   ItemDataBound:数据绑定的时候(正在进行时)发生,多用在Repeater控件嵌套,对子Repeater控件进行数据绑定及模板列中统计列的计算处理等 ...

  2. ASP.NET- 查找Repeater控件中嵌套的控件

    如何在Repeater的HeaderTemplate和FooterTemplate模板中寻找控件?在Repeater的ItemTemplate模板中的控件,我们可以用Items属性来遍历行并用Find ...

  3. Repeater控件三层嵌套-内层Repeater添加绑定事件

    用Repeater三层嵌套,最外层Repeater可以生成自己的ItemCommand事件.但接下来中间层因为是嵌套了的,所以无法在属性窗口中生成自己的事件.如果手动敲入则无效. 解决办法是需要通过编 ...

  4. 使用Repeater控件实现三层嵌套以及分页效果

    PS: 第一次用Repeater控件 记录一下 请忽略我的命名不规范  请忽略我的最终效果图(太丑了) 需要用到的朋友可以自行调整的漂亮点 ====================最终效果图===== ...

  5. Repeater控件 ---表格展示数据

    简介: Repeater控件是Web 服务器控件中的一个容器控件,它使您可以从页的任何可用数据中创建出自定义列表. Repeater 控件不具备内置的呈现功能,这表示用户必须通过创建模板为 Repea ...

  6. asp.net repeater控件操作

    Repeater控件和DataList控件,可以用来一次显示一组数据项.比如,可以用它们显示一个数据表中的所有行. Repeater控件完全由模板驱动,提供了最大的灵活性,可以任意设置它的输出格式. ...

  7. asp.net动态网站repeater控件使用及分页操作介绍

    asp.net动态网站repeater控件使用及分页操作介绍 1.简单介绍 Repeater 控件是一个容器控件,可用于从网页的任何可用数据中创建自定义列表.Repeater 控件没有自己内置的呈现功 ...

  8. ASP.Net中通过Jquery前端对Repeater控件绑定的数据进行操作

    说明:由于Repeater控件是动态绑定,通过Id获取数据只能默认获取第一行: 1.对Repeater中div设置样式 2.通过$(".css").each(function(){ ...

  9. Repeater 控件

    Repeater 控件是一个容器控件,可用于从网页的任何可用数据中创建自定义列表.Repeater 控件没有自己内置的呈现功能,这意味着用户必须通过创建模板来提供 Repeater 控件的布局.当网页 ...

随机推荐

  1. 【转】delphi Format格式化函数

    转自:http://www.cnblogs.com/mumble/archive/2011/05/25/2056462.html Format是一个很常用,却又似乎很烦的方法,本人试图对这个方法的帮助 ...

  2. 2016 Vultr VPS最新优惠码,赠送新用户70美元,亲测有效

    vultr肯定疯了,从来没有哪家海外vps像vultr那么大力度的优惠.近期,vultr vps再度推出优惠码,任何新用户注册即送20美元!要知道,vultr vps最便宜的vps套餐只要5美元/月, ...

  3. IE9 浏览器无法捕获中键事件

    在silverlight中由于需要添加中键事件,所以通过hook来捕获,但是在IE9上无法运行,该问题是由于IE9设置问题,如下图修改配置, 取消选择即可:

  4. Jdk 1.8*安装并配置

     转载自:http://www.cnblogs.com/zlslch/p/5658399.html 简单说下,jdk1.8*的下载,见http://www.cnblogs.com/zlslch/p/5 ...

  5. Network: Why 1472B length of ICMP?

    when ping, specifying the length of the packet by: ping localhost -l 32 Actually default is -l 32, s ...

  6. java 中递归的实现 以及利用递归方法实现汉诺塔

    今天说下java语言中比较常见的一种方法,递归方法. 递归的定义 简单来说递归的方法就是"自己调用自己",通过递归方法往往可以将一个大问题简单化,最终压缩到一个易于处理的程度.对于 ...

  7. Ubuntu 软件 安装 下载 及更新

    1  软件安装 sudo apt-get install 2 软件搜索 sudo   apt-cache search 3  系统已经安装了什么软件 dpkg  -l 是否确切安装了某软件 dpkg ...

  8. Major and minor numbers

    The major nuber is the driver associated with the device, while the minor number is used by the kern ...

  9. CodeForces 703C Chris and Road

    数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车 ...

  10. HDU 5834 Magic boy Bi Luo with his excited tree

    树形dp. 先dfs一次处理子树上的最优解,记录一下回到这个点和不回到这个点的最优解. 然后从上到下可以推出所有答案.细节较多,很容易写错. #pragma comment(linker, " ...