Try the following
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.