repeater 问题

zestsnake 2016-03-29 11:27:34
在最后一行加个总计,中间根据不同种类有合计,所有数据都通过SQL算好了,合计没问题,最后一行的总计出不来,


protected void RpBook_ItemDataBound(object sender, RepeaterItemEventArgs e)
{



if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{

Label lbl_biz = (Label)e.Item.FindControl("lbl_biz");
Label lbl_typename = (Label)e.Item.FindControl("lbl_typename");
Label lbl_saletypename = (Label)e.Item.FindControl("lbl_saletypename");
Label lbl_saletypecust = (Label)e.Item.FindControl("lbl_saletypecust");
Label lbl_salescore = (Label)e.Item.FindControl("lbl_salescore");
Label lbl_salejifen = (Label)e.Item.FindControl("lbl_salejifen");
Label lbl_branchname = (Label)e.Item.FindControl("lbl_branchname");
Label lbl_username = (Label)e.Item.FindControl("lbl_username");
Label lbl_sdate = (Label)e.Item.FindControl("lbl_sdate");
Label lbl_salebranch = (Label)e.Item.FindControl("lbl_salebranch");
Label lbl_saletypeid = (Label)e.Item.FindControl("lbl_saletypeid");
ImageButton im1 = (ImageButton)e.Item.FindControl("IBDelClass");

for (int i = 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 = "----";

}
}
...全文
146 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
zestsnake 2016-03-30
  • 打赏
  • 举报
回复
解决了,对REPEATER的绑定不太了解

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧