Click here to Skip to main content
15,887,476 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using two drop down.

drop1 values contains 8
drop2 alues contains 6.

My validation is drop2 values should be greater always.
It will validate only 10 and above not validating less than 10.

what is the proplem...

see my code
VB
If Trim(drp1.SelectedValue) < Trim(drp2.SelectedValue) Then
           Dim myscript As String = "alert('To values should be greater than from values');"
           System.Web.UI.ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), "myscript", myscript, True)
           drpFrmWk.Focus()
           Flag = False
           Return 0
End If
Posted
Updated 16-Jan-12 22:11pm
v2

Check with this. You are comparing strings instead of integers.
VB
If Convert.ToInt32(Trim(drp1.SelectedValue)) < Convert.ToInt32(Trim(drp2.SelectedValue)) Then
 
Share this answer
 
Try the following


SQL
if (int.Parse(ddl1.SelectedValue.Trim()) >int.Parse(ddl2.SelectedValue.Trim()))
            {
                ScriptManager.RegisterStartupScript(this,this.GetType(),"Test","alert('To value must be greater than from value');",false);

            }

Dropdownlist selected value will be in string format so if you wanna compare the integer values you have to convert them into intergers using any parse/converstion methods

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900