ตั้งคำถาม / ดูคำถาม

คำถาม
 
หัวข้อ
ระบบ error
 
รายละเอียด
Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 602: PD1 = Convert.ToDecimal(txtPD1.Text); PD2 = Convert.ToDecimal(txtPD2.Text); Line 603: F1 = Convert.ToDecimal(txtF1.Text); F2 = Convert.ToDecimal(txtF2.Text); Line 604: S1 = Convert.ToDecimal(txtS1.Text); S2 = Convert.ToDecimal(txtS2.Text); Line 605: U1 = Convert.ToDecimal(txtU1.Text); U2 = Convert.ToDecimal(txtU2.Text); Line 606: Source File: D:MIS2020_SRCCMS2020_SRCVRUClassRoom_Websectiongradeedit.aspx.cs Line: 604 Stack Trace: [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +10164195 System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt) +238 System.Convert.ToDecimal(String value) +100 ClassRoom.sectiongradeedit.dgv_RowCommand(Object sender, GridViewCommandEventArgs e) in D:MIS2020_SRCCMS2020_SRCVRUClassRoom_Websectiongradeedit.aspx.cs:604 System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +149 System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +215 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
 
เขียนโดย    
วัชระ Email kpwat@hotmail.com
 
เขียนเมื่อ   
12 มีนาคม 2556   เวลา 08:02:37 น.
 
คำตอบ
 
โดย    ผศ.วิวัฒน์ ชินนาทศิริกุล วันที่ 12 มีนาคม 2556 เวลา 12:51:24 น.
  เรียน อ.วัชระ
รบกวนอาจารย์ ที่สสว.ให้น้องเก่ง(ฉัตรชัย) ช่วยตรวจสอบให้ครับ
จาก ERROR ที่แสดง ผมไ่ม่ทราบว่าตรงช่องของช่วงคะแนนที่เป็น
PD P NP S U อาจารย์ใส่ค่าว่างไว้ หรือค่า DEFAULT ที่เป็น 0.0 ไว้ครับ
เพราะถ้าเป็นค่าว่างจะเกิด ERROR ในการ CONVERT ค่าเป็น DECIMAL ครับ
จากการที่ผมทดสอบดูถ้าช่วงคะแนนอื่นๆที่ไม่ใช่ A-F ผมไม่ใส่ 0.0 ผมลบทิ้งเป็นค่าว่าง จะเกิด ERROR ตามที่อาจารย์แจ้งมาครับ
ยังไงรบกวนอาจารย์ที่ สสว.นะครับ