Formating a date field in ASP .Net 2.0 detailview

G

Guest

Okay, I am using a detail view to display some data. Two of the fields are
date fields. I can't seem to get them to display properly. I have tried a
variety of options in the DataFormatString property for the columns in
question, but nothing is working. Is there a particular trick to this?
 
G

Guest

If you are using an SQL data source you can also control how the data is
formatted using the CAST and CONVERT funtions in the query it's self so no
formatting is required in the control.
 
Joined
Jan 27, 2010
Messages
27
Reaction score
0
Formating the string before displaying in ASP.NET

In Some cases while displaying a large number it will be nice if we can format the number to a more readable format
Like : Reputation Point : 537456
Can be more readable if we can write it as Reputation Point : 537,456
ASP.NET provide features like String.Format(format,arg0) to format arguments into different forms.
For above solution you can implement

Response.Write(String.Format("{0:#,###}", 123456789));
Which will print 123,456,789

{0:#,###} → Known as the format string where “{ ,}”are compulsory to mentation.
The first part before ':' represent the argument number & it will be an integer.
The second part after ':' represent the format that you want your argument to be converted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top