0

Dear all .Netters,

How do i format gridview columns
to this format :

=> 9,000,000.00
=> 2007-10-05

I tried like this :

DataFormatString="{0:N2}"
DataFormatString="{0:yyyy-MM-dd}"
DataFormatString="{0:N4}"

but not worked.

Current, if format the columns in Rowdatabound events, like this :

Protected Sub GVArticle_RowdataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVFunding.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If IsDate(e.Row.Cells(2).Text.Trim) = True Then
e.Row.Cells(2).Text = SetDateValue(CDate(e.Row.Cells(2).Text.ToString.Trim))
End If
If IsDate(e.Row.Cells(4).Text.Trim) = True Then
e.Row.Cells(4).Text = SetDateValue(CDate(e.Row.Cells(4).Text.ToString.Trim))
End If
If IsDate(e.Row.Cells(5).Text.Trim) = True Then
e.Row.Cells(5).Text = SetDateValue(CDate(e.Row.Cells(5).Text.ToString.Trim))
End If
If IsNumeric(e.Row.Cells(9).Text.Trim) = True Then
e.Row.Cells(9).Text = FormatNumber(e.Row.Cells(9).Text.ToString.Trim, 2, TriState.True)
End If
End If
End Sub

Thanks and Regards

Kusno

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by SheSaidImaPregy
0

For your numbers, do this:

FormatNumber(yourstring,2)
Explanation:
FormatNumber(yourstringtoformat,numberofdecimalplaces)

For your dates, do this:
String.Format("{0:yyyy-MM-dd}",yourstringtoformat)

they will give you the desired outcome you are after.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.