Repeater

Repeater 强制保留两位小数 

View Code
 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="width: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>
View Code
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     }
posted @ 2012-05-07 17:43  一篮饭特稀  阅读(267)  评论(0编辑  收藏  举报