Monday, November 26, 2007

C# Asp.net: Converting string to byte array and Vise versa

System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] myByteArray = enc.GetBytes("a text string");
string myString = enc.GetString(myByteArray );

Sunday, November 18, 2007

C# Asp.net: Date Format in Grid

Format Pattern
Name
Example
d
Short date format
8/27/1989
D
Long date format
Sunday, August 27, 1989
t
Short time format
3:32 PM
T
Long time format
3:32:00 PM
f
Full date/time format(short time)
Sunday, August 27, 1989 3:32 PM
f
Full date/time format(long time)
Sunday, August 27, 1989 3:32:00 PM
g
General date/time format(short time)
8/27/1989 3:32 PM
G
General date/time format(long time)
8/27/1989 3:32:00 PM
m or M
Month day format
August 27
r or R
RFC 1123 format
Sun, 27 Aug 1989 8:32:00 GMT
s
Sortable date/time format
1989-08-27T15:32:00
u
Universable sortable date/time format
1989-08-27 15:32:00z
U
Universable sortable date/time format
Sunday, August 27, 1989 11:32:00 PM
y or Y
Year month format
August, 1989
So, if we have a DataSource field that is a date/time field we can format the field as a just a date (without the time) using the following DataGrid declaration:

About Me

My photo
Alappuzha, Kerala, India