1

我曾经有这样的工作......

 Dim AnnEnt As Label = FormView1.FindControl("Holiday_RemainingLabel")

    txtNoofDays.Text.ToString()
    AnnEnt.Text.ToString()

    If txtNoofDays.Text >= AnnEnt.Text Then

        lblHolRequestResponse.Text = "Your holiday could not be saved"
    Else

我最近把它改成了这个,它不再工作了

    Dim remain As TextBox = FormView1.FindControl("Holiday_RemainingTextBox")



    txtNoofDays.Text.ToString()
    remain.Text.ToString()

    If txtNoofDays.Text >= remain.Text Then

        lblHolRequestResponse.Text = "Your holiday could not be saved"

    Else

表单视图中的文本框和表单视图中的标签之间有什么区别以使其无法正常工作?

从那以后我尝试过...

  Dim days = txtNoofDays.Text

    days.ToString()
    AnnEnt.Text.ToString()
    remain.Text.ToString()
    If remain.Text.ToString < days.ToString Then
        lblHolRequestResponse.Text = "Your holiday could not be saved"
4

1 回答 1

3

如果要比较字符串数字,请将它们转换为数字。

例如(假设它们是ints):

Dim remain As TextBox = FormView1.FindControl("Holiday_RemainingTextBox")
Dim remaining = Int32.Parse(remain.Text)
Dim numOfDays = Int32.Parse(txtNoofDays.Text)

If numOfDays  >= remaining  Then
    lblHolRequestResponse.Text = "Your holiday could not be saved"
End If

Int32.Parse方法

否则,您将按字母顺序进行比较。

String.CompareTo方法

于 2012-04-08T21:59:12.647 回答