Hi Jason,
I'd use a helper function for this. In the code below, you can see that I
call BaseValueHelper which does the division and formats the string before
returning it.
Let us know if this helps?
Ken
Microsoft MVP [ASP.NET]
<%@ page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
If Not IsPostBack Then
dg.DataSource = CreateDataSource()
dg.DataBind()
End If
End Sub
Function BaseValueHelper(ByVal inVal As Double) As String
Dim dblTemp As Double
Try
dblTemp = inVal / 100000
Catch exc As Exception
Return "*Error*"
End Try
Return Format(dblTemp, "###,###,###.00")
End Function
Function CreateDataSource() As Data.DataTable
Dim dt As New Data.DataTable
Dim dr As Data.DataRow
dt.Columns.Add(New Data.DataColumn _
("BaseValue", GetType(Double)))
dt.Columns.Add(New Data.DataColumn _
("StringValue", GetType(String)))
Dim i As Integer
For i = 0 To 1
dr = dt.NewRow()
dr(0) = i + 34000000000
dr(1) = "Item " + i.ToString()
dt.Rows.Add(dr)
Next i
Return dt
End Function
</script>
<html xmlns="
http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Get the value of a column</title>
</head>
<body>
<form id="form1" runat="server">
<columns>
<asp:templatecolumn headertext="BaseValue">
<itemtemplate>
<asp:label runat="server" text='<%#
BaseValueHelper(DataBinder.Eval(Container, "DataItem.BaseValue"))
%>'></asp:label>
</itemtemplate>
</asp:templatecolumn>
<asp:boundcolumn datafield="StringValue"
headertext="StringValue"></asp:boundcolumn>
</columns>
</asp:datagrid>
</div>
</form>
</body>
</html>