在 DataGridview 中,我的字段是Letter Grade
,Minimum Letter Grade
和Maximum Letter Grade
(例如Letter Grade = A-
, Minimum Letter Grade = 85,00
and Maximum Letter Grade = 89,99
)
例如,如果我对其进行更新Minimum Letter Grade = 85,00
,85,99
则将其保存为85,00
.
我怎样才能完全更新它85,99
?
Letter Grade Min
和Letter Grade Max
的数据类型DECIMAL(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>
<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>