Когда я обновляю количество в моей корзине, цена меняется на знак доллара, и все было, и общая сумма также изменилась. Хорошо, но тогда, когда я нажимаю кнопку удаления, она показывает эту ошибку:
Input string was not in a correct format
Как это можно решить? Здесь я предоставляю код:
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AutoGenerateColumns="False" CellPadding="4"
DataSourceID="SqlDataSource2" ForeColor="#333333" GridLines="None"
AllowSorting="True" DataKeyNames="CartID">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="CartID" HeaderText="CartID"
SortExpression="CartID" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="ProductID" HeaderText="ProductID"
SortExpression="ProductID" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="InsertDate" HeaderText="InsertDate"
SortExpression="InsertDate" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity"
SortExpression="Quantity" />
<asp:BoundField DataField="Price" DataFormatString="{0:c}" HeaderText="Price"
SortExpression="Price" />
<asp:BoundField DataField="OrderID" HeaderText="OrderID"
SortExpression="OrderID" />
<asp:BoundField DataField="Total" DataFormatString="{0:c}" HeaderText="Total" SortExpression="Total" />
</Columns>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [ShoppingCart] WHERE [CartID] = @original_CartID AND (([ProductID] = @original_ProductID) OR ([ProductID] IS NULL AND @original_ProductID IS NULL)) AND (([UserName] = @original_UserName) OR ([UserName] IS NULL AND @original_UserName IS NULL)) AND (([InsertDate] = @original_InsertDate) OR ([InsertDate] IS NULL AND @original_InsertDate IS NULL)) AND (([Quantity] = @original_Quantity) OR ([Quantity] IS NULL AND @original_Quantity IS NULL)) AND (([Price] = @original_Price) OR ([Price] IS NULL AND @original_Price IS NULL)) AND (([OrderID] = @original_OrderID) OR ([OrderID] IS NULL AND @original_OrderID IS NULL))"
InsertCommand="INSERT INTO [ShoppingCart] ([ProductID], [UserName], [InsertDate], [Quantity], [Price], [OrderID]) VALUES (@ProductID, @UserName, @InsertDate, @Quantity, @Price, @OrderID)"
OldValuesParameterFormatString="original_{0:c}"
SelectCommand="SELECT [CartID], [ProductID], [UserName], [InsertDate], [Quantity], [Price], [OrderID],(Quantity * Price) as Total FROM [ShoppingCart]"
UpdateCommand="UPDATE [ShoppingCart] SET [ProductID] = @ProductID, [UserName] = @UserName, [InsertDate] = @InsertDate, [Quantity] = @Quantity, [Price] = @Price, [OrderID] = @OrderID WHERE [CartID] = @original_CartID AND (([ProductID] = @original_ProductID) OR ([ProductID] IS NULL AND @original_ProductID IS NULL)) AND (([UserName] = @original_UserName) OR ([UserName] IS NULL AND @original_UserName IS NULL)) AND (([InsertDate] = @original_InsertDate) OR ([InsertDate] IS NULL AND @original_InsertDate IS NULL)) AND (([Quantity] = @original_Quantity) OR ([Quantity] IS NULL AND @original_Quantity IS NULL)) AND (([Price] = @original_Price) OR ([Price] IS NULL AND @original_Price IS NULL)) AND (([OrderID] = @original_OrderID) OR ([OrderID] IS NULL AND @original_OrderID IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_CartID" Type="Int32" />
<asp:Parameter Name="original_ProductID" Type="Int32" />
<asp:Parameter Name="original_UserName" Type="String" />
<asp:Parameter Name="original_InsertDate" Type="DateTime" />
<asp:Parameter Name="original_Quantity" Type="Int32" />
<asp:Parameter Name="original_Price" Type="Decimal" />
<asp:Parameter Name="original_OrderID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ProductID" Type="Int32" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="InsertDate" Type="DateTime" />
<asp:Parameter Name="Quantity" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="OrderID" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ProductID" Type="Int32" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="InsertDate" Type="DateTime" />
<asp:Parameter Name="Quantity" Type="Int32" />
<asp:Parameter Name="Price" Type="Double" />
<asp:Parameter Name="OrderID" Type="Int32" />
<asp:Parameter Name="original_CartID" Type="Int32" />
<asp:Parameter Name="original_ProductID" Type="Int32" />
<asp:Parameter Name="original_UserName" Type="String" />
<asp:Parameter Name="original_InsertDate" Type="DateTime" />
<asp:Parameter Name="original_Quantity" Type="Int32" />
<asp:Parameter Name="original_Price" Type="Decimal" />
<asp:Parameter Name="original_OrderID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>