•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,520 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,814 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 4012 | Replies: 1
![]() |
•
•
Join Date: Aug 2007
Location: Somewhere between heaven and hell
Posts: 112
Reputation:
Rep Power: 2
Solved Threads: 8
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
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
•
•
Join Date: Sep 2007
Posts: 1,058
Reputation:
Rep Power: 4
Solved Threads: 61
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.
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.
Last edited by SheSaidImaPregy : Oct 6th, 2007 at 6:09 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- MultiLine TextBoxes in GridView edit mode (ASP.NET)
- scaner problem: format changes when scaned (Windows 9x / Me)
- How to split datetime format? (ASP.NET)
- how can i display the ms word document in asp page? (ASP)
- Special formatting of a GridView... (ASP.NET)
- Getting values from GridView Controls (ASP.NET)
- Controlling GridView with a ListBox(multible selections enabled) (ASP.NET)
- Controls in GridView (ASP.NET)
- data format from (4.56 0.7) -> 4.6(7) awk?! (Shell Scripting)
- Coin flipping program, so close to finishing (C++)
Other Threads in the ASP.NET Forum
- Previous Thread: How to put procedures in a dynamic input button?
- Next Thread: How to Update a Data Table?



Linear Mode