Repeater 强制保留两位小数
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <asp:Repeater ID="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound"> 2 <HeaderTemplate> 3 <table class="tb_Content" border="0" cellpadding="0" cellspacing="1"> 4 <tr class="tr_Top"><td colspan="29" align="center"><b>项目跟踪管理表</b></td></tr> 5 <tr class="tr_Top"> 6 <td align="center" style="100px;"><b>到款金额</b></td> 7 </tr> 8 </HeaderTemplate> 9 <ItemTemplate> 10 <tr class="tr_Content"> 11 <td align="center"><%#Eval("BilingCount").ToString().Equals(string.Empty) ? "0.00" :Eval("BilingCount","{0:f}")%></td> 12 </tr> 13 </ItemTemplate> 14 <FooterTemplate> 15 <tr class="tr_Content"> 16 <td align="center"><%#BilingCount.Equals(0) ? "0.00" :String.Format("{0:f}",BilingCount)%></td> 17 </tr> 18 </table> 19 </FooterTemplate> 20 </asp:Repeater>
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 public decimal BilingCount = 0; 2 protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 3 { 4 if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 5 { 6 BilingCount += Convert.ToDecimal(DataBinder.Eval(e.Item.DataItem, "BilingCount").ToString().Trim()); 7 } 8 }