Letter Grade
DataGridview には、Minimum Letter Grade
とのフィールドがあります(Maximum Letter Grade
例:Letter Grade = A-
と)Minimum Letter Grade = 85,00
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>