 |
| ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 7th, 2004, 02:43 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Date Formatting in data binding
Hello,
What I need to do is return a date in the format of:
Sept. 7
Where it only returns the month (in short-name format) and day. The closest way I saw was using the "m" format option (returns September 7). I want to be able to do this in a Databinder.Eval expression. A custom method (if possible) could be a possible solution, althought I don't know if you can use methods in the data binding expression.
Or would code-behind binding be preferrable for this?
Thanks,
Brian
__________________
Brian
|
|

September 9th, 2004, 02:27 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
The only way I know to achieve this is to declare an Enum in your code-behind and populate it with the abbreviated month names.
Enum Months
Jan
Feb
Mar
...
End Enum
This way you juct get the corresponding 4rd month name using the following line...
Dim month as String = [Enum].GetName(GetType(Months), 3)
since the starting index is 0. I am also still searching for a built-in formatting function but since I can't find one yet, I'm using this approach instead.
Hope this helps!
Regards,
Marlon
Marlon Villarama
|
|

September 9th, 2004, 03:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi,
<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>
change your formatstring according to Sept. 7
Hope this helps.
--------------------------------------------
Mehdi.:)
|
|

September 9th, 2004, 04:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
The {0:c} is microsoft specific, and I don't think I could implement my own custom formatter. Someone let me know if I'm wrong. At any rate, I implemented something similar to Marlon's idea, except I used a function and a select statement. How I adjusted it was using an ItemDataBound event (I was using a repeater control) and changing the text there.
Thanks for your help,
Brian
|
|

September 9th, 2004, 05:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
try this,
<%# DataBinder.Eval(Container.DataItem, "yourdatecolumn","{0:MMM. d}") %>
--------------------------------------------
Mehdi.:)
|
|

September 10th, 2004, 11:41 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
OK, I'll give it a shot.
|
|
 |