PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Formview (EditView) Money Data Type Binding problem. Help....
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Formview (EditView) Money Data Type Binding problem. Help....
![]() |
Formview (EditView) Money Data Type Binding problem. Help.... |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Folks..
I am trying to use a Simple form with 3 fields from SQL NorthWind Database (Order Details Table with 3 Fields. - OrderId, ProductId and Unit Price). The Field Unit Price has a data type of 'Money Type'. All I want is to able to edit/view/insert 'UnitPrice' field with 2 decimal points instead of 4 decimal points. If I use: Bind("UnitPrice", "{0:c}") in Edit Template, I got: "Input string was not in a correct format...". Although this works in Item Template.... I know I can do it easily in MS Access ADP Form where I set the Decimal Places 'Auto'. It works perfectly without any problem with the same SQL Datasource. I have been trying to use the same ADP logic in .net 2.0 Form View. No luck..... Below is my complete code. Any help/suggestions will be appreciated... I am also new to .net Environment.... - Sam _________________ <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>"> <script runat="server"> </script> <html> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> </div> <br /> <br /> <asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="OrderID,ProductID" DataSourceID="SqlDataSource1" Width="256px"> <EditItemTemplate> OrderID: <asp:Label ID="OrderIDLabel1" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label><br /> UnitPrice: <asp:TextBox ID="UnitPriceTextBox" runat="server" Text='<%# Bind("UnitPrice") %>'></asp:TextBox><br /> ProductID: <asp:Label ID="ProductIDLabel1" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label><br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update"> </asp:LinkButton> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"> </asp:LinkButton> </EditItemTemplate> <InsertItemTemplate> OrderID: <asp:TextBox ID="OrderIDTextBox" runat="server" Text='<%# Bind("OrderID") %>'> </asp:TextBox><br /> UnitPrice: <asp:TextBox ID="UnitPriceTextBox" runat="server" Text='<%# Bind("UnitPrice") %>'> </asp:TextBox><br /> ProductID: <asp:TextBox ID="ProductIDTextBox" runat="server" Text='<%# Bind("ProductID") %>'> </asp:TextBox><br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert"> </asp:LinkButton> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"> </asp:LinkButton> </InsertItemTemplate> <ItemTemplate> OrderID: <asp:Label ID="OrderIDLabel" runat="server" Text='<%# Eval("OrderID") %>'></asp:Label><br /> UnitPrice: <asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Bind("UnitPrice") %>'></asp:Label><br /> ProductID: <asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label><br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton> <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New"></asp:LinkButton> </ItemTemplate> </asp:FormView> <br /> <br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>" DeleteCommand="DELETE FROM [Order Details] WHERE [OrderID] = @OrderID AND [ProductID] = @ProductID" InsertCommand="INSERT INTO [Order Details] ([OrderID], [UnitPrice], [ProductID]) VALUES (@OrderID, @UnitPrice, @ProductID)" SelectCommand="SELECT [OrderID], [UnitPrice], [ProductID] FROM [Order Details]" UpdateCommand="UPDATE [Order Details] SET [UnitPrice] = @UnitPrice WHERE [OrderID] = @OrderID AND [ProductID] = @ProductID"> <DeleteParameters> <asp:Parameter Name="OrderID" Type="Int32" /> <asp:Parameter Name="ProductID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="UnitPrice" Type="Decimal" /> <asp:Parameter Name="OrderID" Type="Int32" /> <asp:Parameter Name="ProductID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="OrderID" Type="Int32" /> <asp:Parameter Name="UnitPrice" Type="Decimal" /> <asp:Parameter Name="ProductID" Type="Int32" /> </InsertParameters> </asp:SqlDataSource> </form> </body> </html> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

