问题描述
在最后一行加个总计,中间根据不同种类有合计,所有数据都通过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的绑定不太了解