如何格式化GridView列? [英] How to format gridview columns?
问题描述
下面是我的代码:
var grid = new GridView();
grid.DataSource = myDataset;
grid.DataBind();
我想将网格的某些列格式化为货币,并用千位分隔符和十进制表示,例如"$ 9,999,999.99".
I want to format some of the columns of my grid to Currency with thousand separator and with decimal like '$9,999,999.99'.
我正在将网格导出到excel,我想查看货币格式的值.
I am exporting the grid to excel and I want to see the values in currency format.
我正在运行时创建gridview.我的Gridview没有html代码.
I am creating gridview during runtime. I have no html code for my gridview.
我只是将数据集绑定到gridview并导出到excel.我不会看到HTML格式的gridview.
I am just bounding dataset to gridview and exporting to excel. I won't see gridview in HTML format.
该怎么做?
推荐答案
Google将我带到了这里,所以我想与我分享我的答案.这是我如何在asp.net中将一个单元格格式化为货币.
Google brought me here, so I thought I'd share my answer. Here's how I got to format one cell to currency in asp.net.
With Me.ratesGridView
.Rows(i).Cells(4).Text = FormatCurrency(.Rows(i).Cells(4).Text)
End With
享受.
这篇关于如何格式化GridView列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!