小数点位置不正确
Incorrect decimal point position
我有一个文本框,我想在其中输入格式为“1.5”的值,当我在文本框中键入“1.5”时,“15.00”将保存到我的数据库中。该值应接受用户的逗号和小数,但小数点的位置需要在第一个数字 (1.5) 之后,并且在 GridView 上显示的分隔符需要是点但它显示逗号。
这是我的文本框。
<asp:TextBox ID="txtCase" runat="server" Width="90px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCase" runat="server" ControlToValidate="txtCase"
ErrorMessage="Required" ForeColor="Red" Display="Dynamic" ValidationGroup="Insert"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revCase" runat="server" ErrorMessage="Decimal Field"
ControlToValidate="txtCase" ForeColor="Red" ValidationExpression="^\d+([,\.]\d{1,2})?$"></asp:RegularExpressionValidator>
我试过:
how to decrease decimal places in gridview column asp.net C#
format a number with commas and decimals in C# (asp.net MVC3)(这是 C#,但我更喜欢使用我的 .aspx 文件)。
我也试过将这些添加到我的文本框中。
DataFormatString="{0:0.00}"
DataFormatString="{0:0.0}"
可惜运气不好。
我不确定我还能更改什么,我在 Stack Overflow 上找到的大多数文章都是关于小数点 之后的内容。
简而言之,我需要插入 1.5 而不是 15.00,我需要我的 GridView 显示点而不是逗号作为分隔符。
GridView 列
<asp:BoundField DataField="Cases" SortExpression="Cases" HeaderText="Cases" Visible="true"
ReadOnly="true" ItemStyle-HorizontalAlign="Center"/>
有什么想法吗?
已添加
Culture="en-US"
进入
<%@ Page
.aspx 文件。
我有一个文本框,我想在其中输入格式为“1.5”的值,当我在文本框中键入“1.5”时,“15.00”将保存到我的数据库中。该值应接受用户的逗号和小数,但小数点的位置需要在第一个数字 (1.5) 之后,并且在 GridView 上显示的分隔符需要是点但它显示逗号。
这是我的文本框。
<asp:TextBox ID="txtCase" runat="server" Width="90px"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvCase" runat="server" ControlToValidate="txtCase"
ErrorMessage="Required" ForeColor="Red" Display="Dynamic" ValidationGroup="Insert"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revCase" runat="server" ErrorMessage="Decimal Field"
ControlToValidate="txtCase" ForeColor="Red" ValidationExpression="^\d+([,\.]\d{1,2})?$"></asp:RegularExpressionValidator>
我试过:
how to decrease decimal places in gridview column asp.net C#
format a number with commas and decimals in C# (asp.net MVC3)(这是 C#,但我更喜欢使用我的 .aspx 文件)。
我也试过将这些添加到我的文本框中。
DataFormatString="{0:0.00}"
DataFormatString="{0:0.0}"
可惜运气不好。
我不确定我还能更改什么,我在 Stack Overflow 上找到的大多数文章都是关于小数点 之后的内容。
简而言之,我需要插入 1.5 而不是 15.00,我需要我的 GridView 显示点而不是逗号作为分隔符。
GridView 列
<asp:BoundField DataField="Cases" SortExpression="Cases" HeaderText="Cases" Visible="true"
ReadOnly="true" ItemStyle-HorizontalAlign="Center"/>
有什么想法吗?
已添加
Culture="en-US"
进入
<%@ Page
.aspx 文件。