repeater 问题

问题描述

在最后一行加个总计,中间根据不同种类有合计,所有数据都通过SQL算好了,合计没问题,最后一行的总计出不来,protectedvoidRpBook_ItemDataBound(objectsender,RepeaterItemEventArgse){if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem){Labellbl_biz=(Label)e.Item.FindControl("lbl_biz");Labellbl_typename=(Label)e.Item.FindControl("lbl_typename");Labellbl_saletypename=(Label)e.Item.FindControl("lbl_saletypename");Labellbl_saletypecust=(Label)e.Item.FindControl("lbl_saletypecust");Labellbl_salescore=(Label)e.Item.FindControl("lbl_salescore");Labellbl_salejifen=(Label)e.Item.FindControl("lbl_salejifen");Labellbl_branchname=(Label)e.Item.FindControl("lbl_branchname");Labellbl_username=(Label)e.Item.FindControl("lbl_username");Labellbl_sdate=(Label)e.Item.FindControl("lbl_sdate");Labellbl_salebranch=(Label)e.Item.FindControl("lbl_salebranch");Labellbl_saletypeid=(Label)e.Item.FindControl("lbl_saletypeid");ImageButtonim1=(ImageButton)e.Item.FindControl("IBDelClass");for(inti=0;i<=RpBook.Items.Count-1;i++){if(((Label)(RpBook.Items[i].FindControl("lbl_salebranch"))).Text==""){((Label)(RpBook.Items[i].FindControl("lbl_biz"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_typename"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_saletypename"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_saletypecust"))).Text="合计";((Label)(RpBook.Items[i].FindControl("lbl_salescore"))).Text="----";((Label)(RpBook.Items[i].FindControl("lbl_branchname"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_username"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_sdate"))).Text="----";}}/*if(((Label)(RpBook.Items[i].FindControl("lbl_salebranch"))).Text==""&&((Label)(RpBook.Items[i].FindControl("lbl_saletypeid"))).Text==""){((Label)(RpBook.Items[i].FindControl("lbl_biz"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_typename"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_saletypename"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_saletypecust"))).Text="总计:";((Label)(RpBook.Items[i].FindControl("lbl_salescore"))).Text="----";((Label)(RpBook.Items[i].FindControl("lbl_branchname"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_username"))).Text="";((Label)(RpBook.Items[i].FindControl("lbl_sdate"))).Text="----";}*/}if(e.Item.ItemType!=ListItemType.Item&&e.Item.ItemType!=ListItemType.AlternatingItem){if(e.Item.ItemIndex==rows-1)//关于总计用了很多方法,都不行,现在是INDEX是-1{((Label)(RpBook.Items[rows-1].FindControl("lbl_biz"))).Text="";((Label)(RpBook.Items[rows-1].FindControl("lbl_typename"))).Text="";((Label)(RpBook.Items[rows-1].FindControl("lbl_saletypename"))).Text="";((Label)(RpBook.Items[rows-1].FindControl("lbl_saletypecust"))).Text="总计:";((Label)(RpBook.Items[rows-1].FindControl("lbl_salescore"))).Text="----";((Label)(RpBook.Items[rows-1].FindControl("lbl_branchname"))).Text="";((Label)(RpBook.Items[rows-1].FindControl("lbl_username"))).Text="";((Label)(RpBook.Items[rows-1].FindControl("lbl_sdate"))).Text="----";}}

解决方案

解决方案二:
解决了,对REPEATER的绑定不太了解

时间: 2024-08-02 05:56:55

repeater 问题的相关文章

Repeater中嵌套Repeater的示例

代码如下: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.dtCategory = GetCategoryTable(); this.dtProduct = GetProductTable(); rptCategoryList.DataSource = dtCategory; rptCategoryList.DataBind(); } } // 准备一张分类表 DataTab

排序-asp.net repeater 绑定数据后 怎么改变显示的顺序

问题描述 asp.net repeater 绑定数据后 怎么改变显示的顺序 <ul style=" margin-left:20px"> <asp:Repeater ID="rep_data" runat="server"> <ItemTemplate> <li ><p ><span><%# Eval("data").ToString()%>:

Repeater中嵌套Repeater的示例介绍

 在某些特殊情况下是需要在Repeater中嵌套使用Repeater的,下面有个不错的示例,感兴趣的朋友可以参考下 代码如下: protected void Page_Load(object sender, EventArgs e)  {  if (!Page.IsPostBack)  {  this.dtCategory = GetCategoryTable();  this.dtProduct = GetProductTable();  rptCategoryList.DataSource

关于多层repeater,datagrid,datalist嵌套的示例

datagrid|示例 常常在CSDN上看到有网友问如何才能实现Repeater,DataList, DataGrid的嵌套问题,下面给出一个3层嵌套的示例,可以无限级嵌套下去 <ASP:REPEATER id="rpt_catalog" onitemdatabound="rpt_catalog_OnItemDataBound" runat="server"> <ITEMTEMPLATE>最顶层repeater,index

在Repeater中嵌套使用Repeater

在一般的网站中浏览类别的用户控件通常都位于大多数 ASP.NET 页的左边,它使用户能够按类别快速的查找产品.最近遇到一个客户,因为在他网站上展示的产品并不多,所以要求在原有类别浏览的基础上将产品也加进去.一来更方便,二来加长了左部导航栏的长度使页面更协调.原有的分类导航栏是由Repeater实现的,现在需要在每一个分类下加入该类的商品信息,于是我想到了在原有Repeater中嵌套Repeater.实现界面如下: 前台页面部分: <asp:Repeater id="rptCategorie

使用嵌套的Repeater控件显示分级数据

控件|数据|显示     简介       本文描述如何使用嵌套的Repeater 控件来显示分级数据 .当然了,你也可以将这一技术应用到其他的列表绑定控件上去,比如DataGrid包含DataGrid,DataList包含DataList等等的组合.       绑定到父表       1.添加一个新的Web Form 到应用程序项目中,名称为Nestedrepeater.ASPx.    2.从工具箱托动一个Repeater 控件到这个页面上, 设定其ID 属性为 parent .    3

使用嵌套的Repeater控件

控件 这个程序适用于:•Microsoft ASP.NET •Microsoft VS.NET 正式版 简介本文描述如何使用嵌套的Repeater 控件来显示分级数据 .当然了,你也可以将这一技术应用到其他的列表绑定控件上去,比如DataGrid包含DataGrid,DataList包含DataList等等的组合. 绑定到父表 1.添加一个新的Web Form 到应用程序项目中,名称为Nestedrepeater.aspx. 2.从工具箱托动一个Repeater 控件到这个页面上, 设定其ID

C#利用repeater 的嵌套实现一个自己想要的日历页面

repeater 控件是一个很灵活的东东,本人在程序开发中就最爱用到它了!!! 很多朋友应该在使用 VS2005 自带的 日历控件的时候 都发现或多或少的 不能满足自己的特殊需求 这个实例看似很简单 但如果能够家里改善 将能很好的运用到自己的程序当中(至少比用JS写个控件简单方便,还能很好的很数据库关联开发),本代码只粘贴出了日历的实现,实际上我用到了四个repeater 的嵌套 实现的是一个日程管理的系统, 剩下的和数据库有关联,所以删掉了! 希望对想使用日历控件的朋友有一定的帮助,注释写的很

ASP.NET 嵌套Repeater

asp.net 本来不怎么用Repeater的,可最近要显示留言板一样的东西,用Grid实现不好看,Grid比较适合正规的WEB系统,对于网站类型的,还是用Repeater了,遇到需要嵌套Repeater的情况,就收藏一下,以后可能还会用到哦.原文来自MS:http://support.microsoft.com/default.aspx?scid=kb;en-us;306154 iew products that this article applies to.Article ID : 306

向 Web 窗体页添加 Repeater 控件

web|控件   向页添加 Repeater Web 服务器控件需要若干步骤.下列过程描述创建一个工作的 Repeater 控件必须执行的最少步骤. 向 Web 窗体页添加 Repeater Web 服务器控件 向 Web 窗体页添加一个数据源.有多种方法可处理页上的数据.若要选择适当的方法,请参见 ADO.NET 数据访问介绍和对 Web 窗体页中数据访问的介绍. 在"设计"视图中,从"工具箱"的"Web 窗体"选项卡将 Repeater 控件