我在本地主机上正确运行但在服务器上显示错误的页面上出现错误。
错误显示为。
[FormatException:输入字符串的格式不正确。] Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(字符串 Value,NumberFormatInfo NumberFormat)+181 Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(字符串 Value,NumberFormatInfo NumberFormat)+63
[InvalidCastException:from string""输入' Double'无效。] Microsoft.VisualBasic.CompilerServices.Conversions.ToDouble(字符串 Value,NumberFormatInfo NumberFormat)+207 Infinity_Billing.BillNS.taxation(String Gross)+485 Infinity_Billing.BillNS.Period_TextChanged(Object sender,EventArgs e)+708 System.Web.UI.WebControls.TextBox.OnTextChanged(EventArgs e)+116 System.Web.UI.WebControls.TextBox.RaisePostDataChangedEvent()+50 System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +10 System.Web.UI.Page.RaiseChangedEvents()+132 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 1644
我认为错误来自税收和Period_TextChanged。
多次更新本地主机上的错误页面,并在localhost上正常工作,完美地保存同一页面。
行gridview上的Taxation和Period Text的代码如下所示。
Protected Sub Period_TextChanged(sender As Object, e As EventArgs)
Dim ddl As TextBox = TryCast(sender, TextBox)
For Each row As GridViewRow In Gridview1.Rows
Dim quan As Control = TryCast(row.FindControl("Qty"), TextBox)
Dim post As Control = TryCast(row.FindControl("Post"), DropDownList)
Dim prd As Control = TryCast(row.FindControl("Period"), TextBox)
If prd IsNot Nothing Then
Dim ddl1 As DropDownList = DirectCast(post, DropDownList)
Dim ddl2 As TextBox = DirectCast(quan, TextBox)
Dim ddl3 As TextBox = DirectCast(prd, TextBox)
If ddl.ClientID = ddl3.ClientID Then
Dim amt As TextBox = TryCast(row.FindControl("Amount"), TextBox)
Dim txt As TextBox = TryCast(row.FindControl("Rate"), TextBox)
If ddl3 Is Nothing Then
MsgBox("Please Insert Nos. of Days Present", vbOKOnly, "Days")
ddl3.Focus()
ElseIf Monthlist.SelectedValue = 0 Then
MsgBox("Please Select Month", vbOKOnly, "Month")
Monthlist.Focus()
Else
amt.Text = ddl1.SelectedValue * ddl2.Text * ddl3.Text / DateTime.DaysInMonth(DateTime.Now.Year, Monthlist.SelectedValue)
GrandTotal()
taxation(Gross_Amount.Text)
Exit For
End If
End If
End If
Next
Private Sub taxation(Gross As String)
If aggrmnt.SelectedValue = 0 Then
MsgBox("Select Aggrement Before Billing", vbOKOnly, "Info")
Else
Using con As SqlConnection = New SqlConnection(strConnString)
Using cmd As SqlCommand = New SqlCommand
cmd.Connection = con
cmd.CommandType = CommandType.Text
cmd.CommandText = "Command Text Here"
Dim dt As New DataTable()
con.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
dt.Load(reader)
ESIC_Amt.Text = ((Gross * dt.Rows(0).Item("ESICDed").ToString.Trim()) / 100)
EPF_Amt.Text = ((Gross * dt.Rows(0).Item("EPFDed").ToString.Trim()) / 100)
Service_Chrg.Text = ((Gross * dt.Rows(0).Item("Ser_Charge").ToString.Trim()) / 100)
Dim temp As Integer = dt.Rows(0).Item("ServiceTaxDed").ToString.Trim()
Dim tempttl As Integer = (Val(ESIC_Amt.Text) + Val(EPF_Amt.Text) + Val(Service_Chrg.Text) + Val(Gross))
Service_Amt.Text = (tempttl * temp / 100)
NetAmt.Text = Val(tempttl) + Val(Service_Amt.Text)
con.Close()
End Using
End Using
End If
天更改从上面的代码中触发period_textchaged事件。
GRAND TOTAL的代码如下所示
Private Sub GrandTotal()
Dim GTotal As Integer
For i As Integer = 0 To Gridview1.Rows.Count - 1
Dim total As Integer = DirectCast(Gridview1.Rows(i).FindControl("Amount"), TextBox).Text
If total.ToString.Length <= 0 Then
total = 0
Else
GTotal += total
End If
'For Each total As [String] In TryCast(Gridview1.Rows(i).FindControl("Amount"), Label).Text
Next
Gross_Amount.Text = GTotal.ToString()
End Sub