473,467 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bind() transform value problem

Hi everybody,

Is there a way to convert a value with Bind()? I have a decimal(5,4)
data that I retrieve from DB, which represents a percent. For example,
50% is represented as 0.5000. When I bind the data to a gridview, I'd
like to see this value as "50", because what I do is a templatefield :
<edititemtemplate>
<asp:textbox text='<%#Bind("value")' runat="server" />
</edititemtemplate>

But is there a way to format the field so it multiplies by a hundred
before binding to the textbox?

Thank you!

ibiza

Feb 1 '06 #1
7 2147
well, I have now Text='Bind("value", "{0:p}")'. which multiplies the
given value by 100, but also shows a % sign...in a textbox where you
enter the percent number, as % sign is unwelcome. Is there a way to
remove it?

thanks

Feb 1 '06 #2
When you say Bind() do you mean DataBinder.Eval (or simply Eval() in 2.0)??

If so, you can specify a 3rd parameter

DataBinder.Eval(Container.DataItem, "value", "{0:p}")

Karl

--
http://www.openmymind.net/

"ibiza" <la******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi everybody,

Is there a way to convert a value with Bind()? I have a decimal(5,4)
data that I retrieve from DB, which represents a percent. For example,
50% is represented as 0.5000. When I bind the data to a gridview, I'd
like to see this value as "50", because what I do is a templatefield :
<edititemtemplate>
<asp:textbox text='<%#Bind("value")' runat="server" />
</edititemtemplate>

But is there a way to format the field so it multiplies by a hundred
before binding to the textbox?

Thank you!

ibiza

Feb 1 '06 #3
I am using asp.net 2.0, which means that Bind("value", "{0:p}") is the
same as DataBinder.Bind(Container.DataItem, "value", "{0:p}") in asp
1.x

thanks for your reply

ibiza

Feb 1 '06 #4
Ibiza Try using Replace function to remove it
Patrick

"ibiza" <la******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
well, I have now Text='Bind("value", "{0:p}")'. which multiplies the
given value by 100, but also shows a % sign...in a textbox where you
enter the percent number, as % sign is unwelcome. Is there a way to
remove it?

thanks

Feb 2 '06 #5
thanks Patrick.

hmmm but how can I use replace in a binding context? I mean,
Bind("value", "{0:p}") is in the aspx file (not in a class of function
full of VB.NET/C# code exclusively), embedded in a gridview
declaration. I tried Replace(Bind("value", "{0:p}") , " %", ""), but it
gives me an error. I guess it can't bind the data correctly anymore if
another function messes the process...

ibiza

Feb 2 '06 #6
Ibiza then do it in the codebehind
i'm sure you must be using a control
in short get the ID of that control whic will give you the "value" u need
and
do what you want to do..
Hope that helps
Patrick

"ibiza" <la******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
thanks Patrick.

hmmm but how can I use replace in a binding context? I mean,
Bind("value", "{0:p}") is in the aspx file (not in a class of function
full of VB.NET/C# code exclusively), embedded in a gridview
declaration. I tried Replace(Bind("value", "{0:p}") , " %", ""), but it
gives me an error. I guess it can't bind the data correctly anymore if
another function messes the process...

ibiza

Feb 3 '06 #7
oookay...but where can I use Bind() and Eval() in code behind ? I
thought it was only in the declaration of a gridview...can you give me
a tiny example?

thanks a lot,

ibiza

Feb 3 '06 #8

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

Similar topics

5
by: Alex Vinokur | last post by:
Functor-parameters in the for_each() and transform() algorithms are passed by value. Might it make sense to have also algorithms for_each2() and transform2() which pass Functor-parameters by...
2
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty...
8
by: Luther Miller | last post by:
I am using the XML tranform functionality in .NET to transform data in a DataSet into XMLSS using an XSLT file I have created. There are about 100 columns and only about 120 rows in the data...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
3
by: b0yce | last post by:
Hi Group, I think I have found a problem with the <xsl:element> when being transformed by the .NET xmlTransform class. When using XmlSpy for development and debugging, the <xsl:number>...
6
by: tcdevelopment | last post by:
I have a XSLT file that gives expected results when I transform using MSXML V4.0 in a simple vbs file. However when using XslTransform in dotnet, I do not get the same results. The part of the...
3
by: Andy | last post by:
Hi all, I'm having a problem doing an Xslt transform in code. I've done it before, so I'm not really sure why its not working. The problem is that the result of the transform is an empty...
3
by: =?iso-8859-1?B?Tm9yZGz2dw==?= | last post by:
Hey there, C++ Coders! I am learning multi-threading with boost and have come up with the following code example shown below. This example implements a test of the producer-consumer design...
3
by: popprem | last post by:
hi, I validated my schema & xml in JAXP. its validated fine. I created the object model in JAXB using xjc command & wn i try to run run the program in throws javax.xml.bind.UnmarshalException:...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.