2011-04-16 58 views
0
protected void LineItemGrid_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    Label lbl3 = (Label)e.Row.FindControl("lbltotal"); 
    if (lbl3 != null) 
    { 
     lbl3.Text = college.Student.Activity[e.Row.RowIndex].Mark1.ToString(); 
     total += decimal.Parse(lbl3.Text); 
    } 
} 

在貨幣格式的價值在aspx頁面如何格式化的GridView

<asp:TemplateField HeaderText="Total" HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="120px" HeaderStyle-HorizontalAlign="Right"> 

回答

0

格式字符串是「c」。

invoicetransmit.Invoice.LineItem[e.Row.RowIndex].TotalNetAmount.ToString("c"); 
+0

我試圖保護無效LineItemGrid_RowDataBound(對象發件人,GridViewRowEventArgs e)上述第{標籤LBL3 =(標籤)e.Row.FindControl( 「lbltotal」); if(lbl3!= null){lbl3.Text = college.Student.Activity [e.Row.RowIndex] .Mark1.ToString(「c」);總數+ = decimal.Parse(lbl3.Text); }它給了我一個錯誤,指出「輸入字符串的格式不正確」。 – Janet 2011-04-16 02:47:51

0
protected void LineItemGrid_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    Label lbl3 = (Label)e.Row.FindControl("lbltotal"); 
    if (lbl3 != null) 
    { 
     lbl3.Text = college.Student.Activity[e.Row.RowIndex].Mark1.ToString("c"); 
     total += decimal.Parse(college.Student.Activity[e.Row.RowIndex].Mark1.ToString()); 
    } 
}