|
-
Oct 16th, 2002, 04:15 PM
#1
Thread Starter
New Member
Datagrid Formatting
Hi,
Is there anyway to set the format value in property builder of a Datgrid control??
I have a datgrid control which is bound to a dataset.
For one of the field in the datagrid i want to set the format to be dd/mm/yy.
There is a Data Formatting Expression option in Property Builder but i don't know to how to specify a value in that?
Is there any other way to set this???
for eg: i have a Date field which basically display date and time.Want to format this to dd/mm/yy when it shows the output in my Datagrid control.
Thanks in advance.
ami.
-
Oct 17th, 2002, 12:04 PM
#2
Junior Member
I usually use the ItemDatabound event of the datagird. Inside the event you could do something like this:
NOTE: This is just scribble... you may have to double check it.
'Let's say your date is in the 3rd cell from the left...
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim strDate = e.Item.Cells(2).Text
e.Item.Cells(2).Text = format(strDate, "mm/dd/yy")
End If
Now, when the item becomes databound, this event will fire and the date will be reformatted.
This may not be the best way... but it works well for me 9 times out of 10.
-
Oct 17th, 2002, 06:53 PM
#3
Hyperactive Member
I do my best to avoid old vb functions and would use the tostring(formatstring) method instead.
-
Oct 17th, 2002, 06:55 PM
#4
Junior Member
Busted
Listen to the Musician
-
Oct 17th, 2002, 07:08 PM
#5
Hyperactive Member
Hehe I'm just being fussy. Now if somebody knew of a way of doing without vbcrlf I'd be rid of System.Microsoft.VisualBasic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|