开发者

HTML text field not displaying decimal places of SQL money value

开发者 https://www.devze.com 2022-12-28 07:35 出处:网络
I have a text field who\'s value is populated from a SQL recordset (below). <input name=\"txtAmount\" id=\"txtAmount\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"<%=RS(\"Amount\")%>\

I have a text field who's value is populated from a SQL recordset (below).

<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10" value="<%=RS("Amount")%>">

In the SQL table, the Amount field (which is a money data type) is inserted correctly, as 5.00 However, in the web page, it displays only as 5 (i.e. the decimal places are missing). Anyone know why this might be and how开发者_如何学编程 I can get the decimal places to display in the field? Thanks!


If you don't want the dollar sign, use

value="<%=FormatNumber(RS("Amount"),2)%>"


Applying formating will do the trick:

<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10" 
       value="<%=FormatCurrency(RS("Amount"), 2)%>">


If your code is in .NET, you can use

<%= String.Format("{0:0.00}", RS("Amount")) %>
0

精彩评论

暂无评论...
验证码 换一张
取 消