S
sck10
Hello,
I am trying to determine if a value is NOT numeric in C#. How do you test
for "Not IsNumeric"?
protected void fvFunding_ItemInserting_Validate(object sender,
FormViewInsertEventArgs e)
if (e.NewValues["Funding"] != "" && Not IsNumeric(e.NewValues["Funding"]))
{
e.Cancel = true;
this.MessageText.Text += "Annual Rev: Numbers only.<br />";
}
}
I tried the following, but it seems awfully cluncky. Thanks, sck10
protected void fvFunding_ItemInserting_Validate(object sender,
FormViewInsertEventArgs e)
// verify the textbox contains an integer
if (e.Values["Funding"].ToString() != "")
{
try {int i = Convert.ToInt32(e.Values["Funding"].ToString(), 10);}
catch (FormatException i)
{
e.Cancel = true;
this.lblMessageText.Text += "Annual Rev: Numbers only.<br />";
}
} // end if
}
I am trying to determine if a value is NOT numeric in C#. How do you test
for "Not IsNumeric"?
protected void fvFunding_ItemInserting_Validate(object sender,
FormViewInsertEventArgs e)
if (e.NewValues["Funding"] != "" && Not IsNumeric(e.NewValues["Funding"]))
{
e.Cancel = true;
this.MessageText.Text += "Annual Rev: Numbers only.<br />";
}
}
I tried the following, but it seems awfully cluncky. Thanks, sck10
protected void fvFunding_ItemInserting_Validate(object sender,
FormViewInsertEventArgs e)
// verify the textbox contains an integer
if (e.Values["Funding"].ToString() != "")
{
try {int i = Convert.ToInt32(e.Values["Funding"].ToString(), 10);}
catch (FormatException i)
{
e.Cancel = true;
this.lblMessageText.Text += "Annual Rev: Numbers only.<br />";
}
} // end if
}