Link to home
Create AccountLog in
Avatar of samprg
samprg

asked on

ASP

Hi,
If I enter alpha in a field,gives me error ,It should just number:

 fe = Convert.ToDecimal(((TextBox)this.rmv.FindControl("txtFee2")).Text == "" ? "0" : ((TextBox)this.rmv.FindControl("txtFee2")).Text);
Avatar of kaufmed
kaufmed
Flag of United States of America image

Try this:
if (decimal.TryParse(((TextBox)this.rmv.FindControl("txtFee2")).Text == "" ? "0" : ((TextBox)this.rmv.FindControl("txtFee2")).Text, out fe))
{
    // If you make it here, the text was a valid decimal and "fe" holds that value
}
else
{
    // If you make it here, the value did NOT represent a valid decimal. "fe" is unchanged.
}

Open in new window

Avatar of samprg
samprg

ASKER

this is  "out fe",gives me error
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of samprg

ASKER

No thing, thanks a lot.
Cool. Glad you got it sorted out  = )