Simon Cripps
asked on
Details view - Input string was not in a correct format
I have a details view on my webpage and this was happily storing the data that I was placing in it. However one of the fields was not storing any decimal places. As I wanted to store decimal places for the field, I changed the database field from type int to type Decimal(10,2) to allow for 2 decimal place. I can type the values with decimal places direct into the cell in the database, but when I try to update with the details view I get a "Input string was not in a correct format" error.
The field is set as a template field and there is no coding behind this bar the expression validator.
How can I resolve this?
The field is set as a template field and there is no coding behind this bar the expression validator.
How can I resolve this?
<asp:TemplateField HeaderText="DiscountPercentage"
SortExpression="DiscountPercentage">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("DiscountPercentage") %>'></asp:TextBox>
<asp:RegularExpressionValidator ID="RequiredFieldValidator4" ControlToValidate="TextBox3" runat="server" ErrorMessage="Percentage discount required" ValidationExpression="^(100(?:\.0{1,2})?|0*?\.\d{1,2}|\d{1,2}(?:\.\d{1,2})?)$"></asp:RegularExpressionValidator>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("DiscountPercentage") %>'></asp:TextBox>
<asp:RegularExpressionValidator ID="RequiredFieldValidator4" ControlToValidate="TextBox3" runat="server" ErrorMessage="Percentage discount required" ValidationExpression="^(100(?:\.0{1,2})?|0*?\.\d{1,2}|\d{1,2}(?:\.\d{1,2})?)$"></asp:RegularExpressionValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server"
Text='<%# Bind("VCDiscountPercentage") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can you give the code behind for the saving.
ASKER
I am using a SQLDatasource to perform this
the field in the datasource is now defined as DiscountPercentage decimal(10,2)
in the SQL update and insert commands the parameter to fill this value is @DiscountPercentage as Decimal(10,2),
The template fields are defined as in the source code attached above.
the field in the datasource is now defined as DiscountPercentage decimal(10,2)
in the SQL update and insert commands the parameter to fill this value is @DiscountPercentage as Decimal(10,2),
The template fields are defined as in the source code attached above.
ASKER
Ahhh, it was the definition of the parameters in the SQLSOURCE, I still had
where as it should of also changed to
Thanks to leading me to check this area again
where as it should of also changed to
Thanks to leading me to check this area again