C
Cesar Ronchese
Hello again!
I'm trying apply a money format in a column in my gridview, but it doesn't work. See the sample:
'create a datatable
Dim dtb As New Data.DataTable
Dim dtr As Data.DataRow
dtb.Columns.Add("col1", GetType(Double))
'add rows to the datatable
dtr = dtb.NewRow
dtr.Item("col1") = 100.13
dtb.Rows.Add(dtr)
dtr = dtb.NewRow
dtr.Item("col1") = 210.27
dtb.Rows.Add(dtr)
'create a column
Dim cCol As BoundField
cCol = New BoundField
'set the column
cCol.DataField = "col1"
cCol.HeaderText = "This column should be formatted"
cCol.DataFormatString = "{0:C2}"
'start the grid
GridView1.Columns.Add(cCol)
GridView1.AutoGenerateColumns = False
GridView1.DataSource = dtb
GridView1.DataBind()
What I'm missing?
PS: I'm using VB and ASP.Net 2005
Cesar
I'm trying apply a money format in a column in my gridview, but it doesn't work. See the sample:
'create a datatable
Dim dtb As New Data.DataTable
Dim dtr As Data.DataRow
dtb.Columns.Add("col1", GetType(Double))
'add rows to the datatable
dtr = dtb.NewRow
dtr.Item("col1") = 100.13
dtb.Rows.Add(dtr)
dtr = dtb.NewRow
dtr.Item("col1") = 210.27
dtb.Rows.Add(dtr)
'create a column
Dim cCol As BoundField
cCol = New BoundField
'set the column
cCol.DataField = "col1"
cCol.HeaderText = "This column should be formatted"
cCol.DataFormatString = "{0:C2}"
'start the grid
GridView1.Columns.Add(cCol)
GridView1.AutoGenerateColumns = False
GridView1.DataSource = dtb
GridView1.DataBind()
What I'm missing?
PS: I'm using VB and ASP.Net 2005
Cesar