gpt4 book ai didi

c# - 如何使用十进制?

转载 作者:行者123 更新时间:2023-11-29 01:03:43 24 4
gpt4 key购买 nike

在 DataGridview 中,我的字段是 Letter Grade , Minimum Letter GradeMaximum Letter Grade (例如 Letter Grade = A-Minimum Letter Grade = 85,00Maximum Letter Grade = 89,99)

例如,如果我更新 Minimum Letter Grade = 85,0085,99它保存为 85,00 .

我怎样才能像85,99一样更新它?

Letter Grade Min 的数据类型和 Letter Grade MaxDECIMAL(4,2)在数据库中。

    public static void updateGradeRanges(string LetterGrd, double LgMin, double LgMax)
try
{
string cmdText = "UPDATE grade_range SET LG_MIN='" + LgMin + "', LG_MAX='" + LgMax + "' WHERE Letter_Grade='" + LetterGrd + "';";
MySqlCommand cmd = new MySqlCommand(cmdText, DB.Conn);
int result = cmd.ExecuteNonQuery();

}

我向这样的函数发送参数:

updateGradeRanges(LetterGrade,Convert.ToDouble(txtMinGrade.Text),Convert.ToDouble(txtMaxGrde.Text));
<asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="true">
<ContentTemplate>
<asp:GridView ID="Grades_GridView" runat="server" BackColor="White" BorderColor="White"
BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
GridLines="None" AutoGenerateColumns="False"
DataKeyNames="Letter_Grade"
onrowcancelingedit="Grades_GridView_RowCancelingEdit"
onrowediting="Grades_GridView_RowEditing"
onrowupdating="Grades_GridView_RowUpdating"
onrowdeleting="Grades_GridView_RowDeleting">

<Columns>
<asp:TemplateField HeaderText="Letter Grade" SortExpression="Letter_Grade">

<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Letter_Grade") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Minimum Letter Grade" SortExpression="LG_MIN">
<EditItemTemplate>
<asp:TextBox ID="txtMinGrade" runat="server" Text='<%# Bind("LG_MIN") %>'></asp:TextBox>
</EditItemTemplate>

<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("LG_MIN") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Maximum Letter Grade" SortExpression="LG_MAX">
<EditItemTemplate>
<asp:TextBox ID="txtMaxGrade" runat="server" Text='<%#Bind("LG_MAX") %>'></asp:TextBox>
</EditItemTemplate>

<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("LG_MAX") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Edit" ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButtonUpdateGrade" runat="server" CommandName="Update" CausesValidation="True"><span class="link_span_small">Update</span></asp:LinkButton>&nbsp;
<asp:LinkButton ID="LinkButtonCancelGrade" runat="server" CommandName="Cancel" CausesValidation="True"><span class="link_span_small">Cancel</span></asp:LinkButton>
</EditItemTemplate>

<ItemTemplate>
<asp:ImageButton ID="ImageButtonEditGrade" runat="server" CausesValidation="False"
CommandName="Edit" ToolTip="Edit" ImageUrl="~/Images/edit.png" />
</ItemTemplate>
</asp:TemplateField>
</Columns>


<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#594B9C" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#33276A" />


</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>

最佳答案

从您的 sql 更新语句中删除单引号。

关于c# - 如何使用十进制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16243901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com