簡體   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