By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,825 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

display float

P: n/a
I have a databind in a repeater control
<%#Eval("Score")%>

Score is a float
float Score = 3.2;
However the html output is always 3 I cannot make it display 3.2.

PLease help,
Howard
May 28 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Try this:

<%#Eval("Score").ToString("n")%>

If you need to specify how many decimal places to use, do the following (the
following will use 10 decimal places, adjust this to your preference):

<%#Eval("Score").ToString("n10")%>

If you have any questions, feel free to ask. You can also see Visual
Studio's section on "Format Specifiers" for more detail. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl...
I have a databind in a repeater control
<%#Eval("Score")%>

Score is a float
float Score = 3.2;
However the html output is always 3 I cannot make it display 3.2.

PLease help,
Howard

May 29 '06 #2

P: n/a
I tried that it says
No overload for method 'ToString' takes '1' arguments

object.ToString()
There has to be a way to display decimals.
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
Try this:

<%#Eval("Score").ToString("n")%>

If you need to specify how many decimal places to use, do the following
(the following will use 10 decimal places, adjust this to your
preference):

<%#Eval("Score").ToString("n10")%>

If you have any questions, feel free to ask. You can also see Visual
Studio's section on "Format Specifiers" for more detail. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl...
I have a databind in a repeater control
<%#Eval("Score")%>

Score is a float
float Score = 3.2;
However the html output is always 3 I cannot make it display 3.2.

PLease help,
Howard


May 29 '06 #3

P: n/a
Try this (my suggestion is not really the one I would have used, but it
looked like the one you would have preferred, but I admit I didn't actually
try that one):

<%# DataBinder.Eval(Container, "DataItem.Score","{0:n}") %>

or to specify the number of decimals:

<%# DataBinder.Eval(Container, "DataItem.Score","{0:n10}") %>
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
I tried that it says
No overload for method 'ToString' takes '1' arguments

object.ToString()
There has to be a way to display decimals.
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
Try this:

<%#Eval("Score").ToString("n")%>

If you need to specify how many decimal places to use, do the following
(the following will use 10 decimal places, adjust this to your
preference):

<%#Eval("Score").ToString("n10")%>

If you have any questions, feel free to ask. You can also see Visual
Studio's section on "Format Specifiers" for more detail. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl...
I have a databind in a repeater control
<%#Eval("Score")%>

Score is a float
float Score = 3.2;
However the html output is always 3 I cannot make it display 3.2.

PLease help,
Howard



May 29 '06 #4

P: n/a
Thanks it works now

What is the difference between
Eval()?
and
DataBinder.Eval()?
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP03.phx.gbl...
Try this (my suggestion is not really the one I would have used, but it
looked like the one you would have preferred, but I admit I didn't
actually try that one):

<%# DataBinder.Eval(Container, "DataItem.Score","{0:n}") %>

or to specify the number of decimals:

<%# DataBinder.Eval(Container, "DataItem.Score","{0:n10}") %>
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
I tried that it says
No overload for method 'ToString' takes '1' arguments

object.ToString()
There has to be a way to display decimals.
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
Try this:

<%#Eval("Score").ToString("n")%>

If you need to specify how many decimal places to use, do the following
(the following will use 10 decimal places, adjust this to your
preference):

<%#Eval("Score").ToString("n10")%>

If you have any questions, feel free to ask. You can also see Visual
Studio's section on "Format Specifiers" for more detail. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl...
I have a databind in a repeater control
<%#Eval("Score")%>

Score is a float
float Score = 3.2;
However the html output is always 3 I cannot make it display 3.2.

PLease help,
Howard



May 30 '06 #5

P: n/a
I'm not sure there is a difference in this case, but in some cases they are
methods with the same name from different classes. I have been taught to use
DataBinder just to be safe, but if you prefer you can probably use just
Eval(). For more detail, see the documentation.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:On**************@TK2MSFTNGP02.phx.gbl...
Thanks it works now

What is the difference between
Eval()?
and
DataBinder.Eval()?
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP03.phx.gbl...
Try this (my suggestion is not really the one I would have used, but it
looked like the one you would have preferred, but I admit I didn't
actually try that one):

<%# DataBinder.Eval(Container, "DataItem.Score","{0:n}") %>

or to specify the number of decimals:

<%# DataBinder.Eval(Container, "DataItem.Score","{0:n10}") %>
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
I tried that it says
No overload for method 'ToString' takes '1' arguments

object.ToString()
There has to be a way to display decimals.
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:OM**************@TK2MSFTNGP04.phx.gbl...
Try this:

<%#Eval("Score").ToString("n")%>

If you need to specify how many decimal places to use, do the following
(the following will use 10 decimal places, adjust this to your
preference):

<%#Eval("Score").ToString("n10")%>

If you have any questions, feel free to ask. You can also see Visual
Studio's section on "Format Specifiers" for more detail. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Howard" <ho*******@yahoo.com> wrote in message
news:e1**************@TK2MSFTNGP02.phx.gbl...
>I have a databind in a repeater control
> <%#Eval("Score")%>
>
> Score is a float
> float Score = 3.2;
> However the html output is always 3 I cannot make it display 3.2.
>
> PLease help,
> Howard
>



May 30 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.