Could ANYONE check on my code. As I compare the DSO with the DSO para, it seems doesn't compare both data at all. I have been converting the DSO as double first between comparing it as if i compare with string it doesn't work. anyone could help me please. I need it urgently

Dim dso1 As Label = CType(e.Item.FindControl("dso1"), Label)
        If Not IsNothing(dso1) Then
            dso1.Text = e.Item.DataItem("DSO").ToString
            If e.Item.DataItem("DSO").ToString < e.Item.DataItem("DSO_para").ToString Then
                dso1.BackColor = Drawing.Color.Transparent
            ElseIf Double.Parse(e.Item.DataItem("DSO").ToString) >= Double.Parse(e.Item.DataItem("DSO_para").ToString) Then
                dso1.BackColor = Drawing.Color.Red
            End If
            If dso1.Text = "" Then
                dso1.Text = "N/A"

            End If
        End If

Recommended Answers

All 3 Replies

You say it doesn't compare both data. By that do you mean check the string version is less than DSO_para and then check that the double version is > DSO_para? Because you use ElseIF statement which won't check them both..

Or is it not comparing the string version against the string and the double against the double in each If statement?

I want the dso to check with the parameter dso_para . but it seems nothing happened. What is wrong with my elseif statement? Could you fixed it for me. Could string compare with string? or i need to convert it to double/integer first before check?

Time to debug your bug and see what values are in DSO and dso_para. You can compare strings with strings (abc < bcd, etc) so in theory what you are doing is possible. But now you need to check if DSO IS less than dso_para as a string or higher as a double because if neither condition is true nothing will happen.
Don't worry about your if statement, I'm not sure what I was thinking at the time but if the first is true then the second one can't be so you don't need to check both. Had a mind blank:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.