繁体   English   中英

为什么我的价格在更新后变成了 RM0.00?

[英]Why my value for price turns to RM0.00 after update?

这是我的前端代码

我试图从 double 更改为 float 和 char 但同样的事情发生了。 即使我更新数量,价格部分也会变为 0.00。 如何解决这个问题?

<td><asp:Label ID="lblPPrice" runat="server" Text='<%# Eval("PPrice","{0:c}")
 %>' ></asp:Label>
            <asp:TextBox ID="txtPPrice" runat="server" Text='<%# Eval("PPrice","
 {0:c}") %>' Visible="false"></asp:TextBox> </td>

             <td><asp:Label ID="lblPSelPrice" runat="server" Text='<%#
 Eval("PSelPrice","{0:c}") %>' ></asp:Label>
            <asp:TextBox ID="txtPSelPrice" runat="server" Text='<%#
 Eval("PSelPrice","{0:c}") %>' Visible="false"></asp:TextBox> </td>

这是我背后的代码

cmd.Parameters.AddWithValue("@PPrice", SqlDbType.NVarChar).Value =
double.TryParse(productPrice, out money);
           cmd.Parameters.AddWithValue("@PSelPrice", SqlDbType.NVarChar).Value=
double.TryParse(productSelPrice, out money);

TryParse 方法返回布尔值。 尝试分配货币变量。

if(double.TryParse(productPrice, out money))
{
   cmd.Parameters.AddWithValue("@PPrice", SqlDbType.NVarChar).Value = money;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM