Mike,
A suggestion would be to scrap this code behind and go with client side
validation. What you're doing isn't wrong, but it does mean a post-back has
to a occur before the user will see their error. It's better to have a
CompareValidator that contains your text error string, where the operator =
"DataTypeCheck" and the Type is "Integer"...
This will only allow a postback if the value in the textbox is an integer.
Google on CompareValidator for more, or let me know if you need more help.
Daniel.
"MrMike" <Mr****@discussions.microsoft.com> wrote in message
news:3C**********************************@microsof t.com...
Hi. I'm trying to create a simple validation process that only allows a
user
to enter a numeric value into a textbox. However, my process does not
work
and the user can still enter non-numeric values. My code is below. How
can
I fix this? Thanks.
If Not (IsNumeric(CType(e.Item.Cells(3).Controls(0), TextBox).Text)) Then
Me.lblErrorMsg.Text = "Only numeric values allowed!"
Exit Sub
End If