1
基本上我試圖讓一個複選框列表能夠讓我選擇幾種不同的選項來選擇發票的「各種費用」。 到目前爲止,一切都是成功的,但我不能選擇多個費用沒有頁面崩潰。試圖選擇複選框列表中的幾個選項
這是它是如何應該是一個例子:http://aspnet.cob.ohio.edu/matta/asppub/MIS3200/Unit4/BobcatU4L22.aspx
這是我當前的代碼:有關該錯誤以及它起源於代碼
if (cblFees.Items[0].Selected)
{
decFees = decFees + Convert.ToDecimal(cblFees.Items[0].Value);
}
if (cblFees.Items[1].Selected)
{
decFees = decFees + Convert.ToDecimal(cblFees.Items[1].Value);
}
if (cblFees.Items[2].Selected)
{
decFees = decFees + Convert.ToDecimal(cblFees.Items[2].Value);
}
if (cblFees.Items[3].Selected)
{
decFees = decFees + Convert.ToDecimal(cblFees.Items[3].Value);
}
if (cblFees.Items[4].Selected)
{
decFees = decFees + Convert.ToDecimal(cblFees.Items[4].Value);
}
if (decStateTaxRate == 0.00M)
{
lblOutputCheckBoxList.Visible = true;
lblOutputCheckBoxList.Text = "The State Code was not recognized.";
}
if (decStateTaxRate > 0.00M)
{
decCalculatedStateTax = (decStateTaxRate * decSales);
decTotalDue = (decCalculatedStateTax + decSales);
lblOutputCheckBoxList.Visible = true;
lblOutputCheckBoxList.Text = "Your state is: " + strState + "<br />" + " the tax rate is " + decStateTaxRate + "<br />" +
"Sales Tax = " + decCalculatedStateTax.ToString("C2") + "<br />" + "Fees (after sales tax) = " + decFees + "<br />" + "Total Due = " + decTotalDue.ToString("C2");
}
Server Error in '/asppub' Application. 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
信息。
Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 177: if (cblFees.Items[0].Selected) Line 178: { Line 179: decFees = decFees + Convert.ToDecimal(cblFees.Items[0].Value); Line 180: } Line 181: if (cblFees.Items[1].Selected) Source File: c:\Users\Ryan\Desktop\asppub\MIS3200\Unit4\RingU4L2.2.aspx.cs Line:
System.Number.ParseDecimal(字符串值,的NumberStyles選項的NumberFormatInfo numfmt)146 System.Convert.ToDecimal(字符串值)68 MIS3200_Unit4_RingU4L1。 btnCheckBox_Click(Object sender,EventArgs e) c:\ Users \ Ryan \ Desktop \ asppub \ MIS3200 \ Unit4 \ RingU4L2.2.aspx.cs:179 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebC ontrols.Button.RaisePostBackEvent(字符串eventArgument)112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(字符串 eventArgument)10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,字符串eventArgument)13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection中POSTDATA)36 System.Web.UI.Page.ProcessRequestMain(布爾includeStagesBeforeAsyncPoint,布爾includeStagesAfterAsyncPoint)Stack Trace: [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
頁面崩潰? – Ofiris
你得到的錯誤究竟是什麼? 「頁面崩潰」不是很有幫助。 –
請嘗試在這裏抓取並粘貼錯誤,以便我們瞭解確切的問題。 – ARH