有沒有辦法將gridview列腳註值的格式設置爲貨幣。我將BoundField的DataFormatString設置爲{0:c},但這似乎不影響頁腳。我是否必須在RowDataBound事件中執行此操作?Gridview頁腳數據格式字符串
0
A
回答
0
我結束了在類似這樣的方式做...
protected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
double dVal = 0.0;
if (e.Row.RowType == DataControlRowType.DataRow)
{
dVal += Convert.ToDouble(e.Row.Cells[1].Text);
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Text = dVal.ToString("c");
}
}
0
您是否在頁腳上設置了HtmlEncode =「False」?
編輯:這一直是一個已知的問題。
0
這是一個雜牌組裝電腦。 (sp?)
但是有時候在遇到已知問題時,你得弄爛。 (?SP)
private static string FormatByGridView(object value, string DataFormatString)
{
GridView grid = new GridView();
DataTable table = new DataTable();
table.Columns.Add("value", value.GetType());
var row = table.NewRow();
row["value"] = value;
table.Rows.Add(row);
grid.Columns.Add(new BoundField() { DataField = "value", DataFormatString = DataFormatString });
grid.DataSource = table;
grid.DataBind();
return grid.Rows[0].Cells[0].Text;
}
0
這個工作對我來說:
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[2].Text = string.Format("{0:#,###,###.00}", total2013);
e.Row.Cells[3].Text = string.Format("{0:#,###,###.00}", total2014);
}
相關問題
- 1. 根據格式字符串
- 2. 格式字符串和獲取數據
- 3. NMEA格式GPS數據字符串
- 4. 格式化字符串從數據
- 5. 格式數字字符串到另一個數字字符串
- 6. PHP格式化數據字符串到MySQL日期格式
- 7. 字符串格式
- 8. 字符串格式
- 9. 格式字符串
- 10. 格式字符串
- 11. 格式字符串
- 12. 字符串格式符號
- 13. 格式字符串數字到貨幣
- 14. JavaScript中的數字字符串格式
- 15. 格式字符串/數字「NNNNN」
- 16. 將字符串格式化爲數字
- 17. 格式化蟒蛇數字,字符串
- 18. 從字符串和數據表中格式化Json數據
- 19. 如何讀取JSON格式的字符串數據數據?
- 20. 使用字符串格式給出字符串值的格式
- 21. 字符串格式化在格式化整個字符串
- 22. 格式化字符串數量(複數)
- 23. Gridview頁腳的單獨數據源
- 24. 字符串與頁眉和頁腳PDF
- 25. gridview e.CommandArgument字符串沒有正確格式化
- 26. 輸入字符串與GridView中的TemplateField格式不正確
- 27. 在GridView編輯上,「輸入字符串的格式不正確」
- 28. 字符串格式時導出到Excel從GridView的
- 29. 輸入字符串格式不正確以檢索gridview值
- 30. GridView - 輸入字符串格式不正確