473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

DateTimeFormat

gh
I am trying to format a datetime in a datalist label. Below is the aspx
code I have, but I get an error: The name 'Format' does not exist in the
current context.

How do I format the datetime to display the date portion only in the label.

TIA
<asp:Label id="ProjectDateLabel" runat="server"
text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:
Oct 1 '07 #1
6 2913
On Oct 1, 6:57 pm, gh <g...@att.netwrote:
I am trying to format a datetime in a datalist label. Below is the aspx
code I have, but I get an error: The name 'Format' does not exist in the
current context.

How do I format the datetime to display the date portion only in the label.

TIA

<asp:Label id="ProjectDateLabel" runat="server"
text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:
C#?

Try string.Format

Oct 1 '07 #2
Try this
<%# DataBinder.Eval(Container.DataItem, "ProjectDate", "{0:dd/MM/yyyy}") %>

Or my guess <%# Eval("ProjectDate", "{0:dd/MM/yyyy}") % (never worked with
that, awlays used DataBinder object)

George

"gh" <gh@att.netwrote in message
news:OL****************@TK2MSFTNGP06.phx.gbl...
>I am trying to format a datetime in a datalist label. Below is the aspx
code I have, but I get an error: The name 'Format' does not exist in the
current context.

How do I format the datetime to display the date portion only in the
label.

TIA
<asp:Label id="ProjectDateLabel" runat="server"
text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:

Oct 1 '07 #3
gh
George Ter-Saakov wrote:
Try this
<%# DataBinder.Eval(Container.DataItem, "ProjectDate", "{0:dd/MM/yyyy}") %>

Or my guess <%# Eval("ProjectDate", "{0:dd/MM/yyyy}") % (never worked with
that, awlays used DataBinder object)

George

"gh" <gh@att.netwrote in message
news:OL****************@TK2MSFTNGP06.phx.gbl...
>>I am trying to format a datetime in a datalist label. Below is the aspx
code I have, but I get an error: The name 'Format' does not exist in the
current context.

How do I format the datetime to display the date portion only in the
label.

TIA
<asp:Label id="ProjectDateLabel" runat="server"
text='<%#Format(Eval("ProjectDate"),"d/M/yyyy")%>'></asp:Label>Address:


George:

That did it. Do you by chance know how to make an image a hyper link?
Below is the code I have.

<asp:Image id="Image1" runat="server" height="125px" width="125px"
imagealign="Left" imageurl='<%# "images/" +
DataBinder.Eval(Container.DataItem, "PHOTOID")%>'></asp:image>&nbsp;PhotoID:

TIA
Oct 1 '07 #4
Do not try to make everything as a Server control. Usually image should not
be a server control.

Do something like this
<a href="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>" >
<img src="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>"
height="125px" width="125px" >
</a>

PS: Nothing prevents you from making it as a server control and use
<asp:Image<asp:Link>. You will just consume more resources if you are not
using them as a server controls.

George.
Do you by chance know how to make an image a hyper link? Below is the code
I have.

<asp:Image id="Image1" runat="server" height="125px" width="125px"
imagealign="Left" imageurl='<%# "images/" +
DataBinder.Eval(Container.DataItem,
"PHOTOID")%>'></asp:image>&nbsp;PhotoID:

TIA

Oct 1 '07 #5
gh
George Ter-Saakov wrote:
Do not try to make everything as a Server control. Usually image should not
be a server control.

Do something like this
<a href="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>" >
<img src="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>"
height="125px" width="125px" >
</a>

PS: Nothing prevents you from making it as a server control and use
<asp:Image<asp:Link>. You will just consume more resources if you are not
using them as a server controls.

George.

>>Do you by chance know how to make an image a hyper link? Below is the code
I have.

<asp:Image id="Image1" runat="server" height="125px" width="125px"
imagealign="Left" imageurl='<%# "images/" +
DataBinder.Eval(Container.DataItem,
"PHOTOID")%>'></asp:image>&nbsp;PhotoID:

TIA


George:

When the image is clicked I have a value of anther field I need to pass
in the url. I use the code below in a link to do this and it works
great. Can this be done without using runat server? Anyway the
<asp:HyperLink runat="server" navigateurl='<%#"selphotos.aspx?id="+
DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
id="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"PrjID")%></asp:HyperLink>

What I was trying was to use the code below with the image, but it
doesn' t act as a link, when clicked.

<asp:HyperLink><asp:Image id="Image1" runat="server" height="125px"
width="125px"
imagealign="Left" runat="server" navigateurl='<%#"selphotos.aspx?id="+
DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
id="Hyperlink1"><%# "images/" +
DataBinder.Eval(Container.DataItem,"PHOTOID")%>'></asp:image></asp:HyperLink>

TIA

Oct 2 '07 #6
On Oct 2, 2:24 am, gh <g...@att.netwrote:
George Ter-Saakov wrote:
Do not try to make everything as a Server control. Usually image shouldnot
be a server control.
Do something like this
<a href="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>">
<img src="images/<%# DataBinder.Eval(Container.DataItem, "PHOTOID")%>"
height="125px" width="125px" >
</a>
PS: Nothing prevents you from making it as a server control and use
<asp:Image<asp:Link>. You will just consume more resources if you arenot
using them as a server controls.
George.
>Do you by chance know how to make an image a hyper link? Below is the code
I have.
<asp:Image id="Image1" runat="server" height="125px" width="125px"
imagealign="Left" imageurl='<%# "images/" +
DataBinder.Eval(Container.DataItem,
"PHOTOID")%>'></asp:image>&nbsp;PhotoID:
>TIA

George:

When the image is clicked I have a value of anther field I need to pass
in the url. I use the code below in a link to do this and it works
great. Can this be done without using runat server? Anyway the

<asp:HyperLink runat="server" navigateurl='<%#"selphotos.aspx?id="+
DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
id="Hyperlink1"><%#DataBinder.Eval(Container.DataI tem,
"PrjID")%></asp:HyperLink>

What I was trying was to use the code below with the image, but it
doesn' t act as a link, when clicked.

<asp:HyperLink><asp:Image id="Image1" runat="server" height="125px"
width="125px"
imagealign="Left" runat="server" navigateurl='<%#"selphotos.aspx?id="+
DataBinder.Eval(Container.DataItem, "ExternalId").ToString()%>'
id="Hyperlink1"><%# "images/" +
DataBinder.Eval(Container.DataItem,"PHOTOID")%>'></asp:image></asp:HyperLin*k>

TIA- Hide quoted text -

- Show quoted text -
An image with a hyper link on html page can be created using a mix of
<aand <imgtags. In ASP.NET, the <imgtag is rendered through the
Image control and <athrough the HyperLink. Note, neither <imgnor
Image control has a destination link property (navigateurl in your
case).

There is another control, named ImageButton, take a look, maybe this
helps
http://samples.gotdotnet.com/quickst..._imagebut.aspx

..NET server control cannot work without runat=server.

Oct 2 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Vottero | last post by:
When a class contains a TimeSpan property, XmlSerializer doesn't work. A TimeSpan property is serialized like: <MySpan /> I've read a number of posts that talk about why this happens and how...
4
by: Karunakararao | last post by:
Hi All Date/Time: 9/29/2004 6:02:13 PM This date and time Iam getting from Database,but I want to remove seconds ":13" Just I want to remove this Like ":13". I want like this : 9/29/2004...
0
by: Muralidhar Chennoju | last post by:
Hi All How to get the Current DateFormat based on the regional settings. The following statment is giving right data when it is windows based application, but when I try the same in Web...
8
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as...
6
by: bojan.pikl | last post by:
Hi, I am making a calendar. It is costum made and I would like to have the ability to choose the first day (Monday or Sunday). I know for the firstDayOfWeek, but I can't change it. What should I do?
7
by: bojan.pikl | last post by:
Hi, I am making a calendar. It is costum made and I would like to have the ability to choose the first day (Monday or Sunday). I know for the firstDayOfWeek, but I can't change it. What should I...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
5
by: CKKwan | last post by:
Dear All, Anybody know how can I get the Work Week of a given date using CSharp? Example, in SQL Server we can get using DATEPART(ww, date); I need something equavalent. Thanks In Advance
11
by: John Dann | last post by:
Is there a concise/efficient way to retrieve blocks of rows from a datatable with VB2005? I've got a datatable (let's call it AllData), constructed programmatically, that contains a lot of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.