[英]Why my value for price turns to RM0.00 after update?
This is my front-end code这是我的前端代码
I have tried to change from double to float and char but same thing happen.我试图从 double 更改为 float 和 char 但同样的事情发生了。 Even when I update quantity, the price part change to 0.00.
即使我更新数量,价格部分也会变为 0.00。 How to fix this issue?
如何解决这个问题?
<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>
This is my code behind这是我背后的代码
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 method returns bool value. TryParse 方法返回布尔值。 Try assigning money variable.
尝试分配货币变量。
if(double.TryParse(productPrice, out money))
{
cmd.Parameters.AddWithValue("@PPrice", SqlDbType.NVarChar).Value = money;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.