I am pulling data from textboxes in my Gridview footer. Some of the fields should be numeric, but when I check for numeric even though there is a numeric value, the code kicks it out as a none numeric, probably because of the quotes surrounding the number
like: "12"
How can I convert to numeric to check for numeric value?
Input "12". IsNumeric(newCPM) renders as False.
Dim newCPM As TextBox = GridView1.FooterRow.FindControl("newCPM")
If IsNumeric(newCPM) Then
Else
Me.GridView1.Caption = "CPM must be Numeric!"
Me.GridView1.Caption = "<span style='color:Red;'>" & Me.GridView1.Caption & "</span>"
Exit Sub
End If
Dim newCPMAsInt As Integer
If Integer.TryParse(newCPM.Text, newCPMAsInt) Then
' newCPM successfully parsed as Integer
Else
' newCPM is not an Integer
End If
Thanks, Sumit.
/**** Please remember to "Mark as Answer" the responses that resolved your issue. ****/
Member
483 Points
2238 Posts
Inserting from data in Gridview Footer fields
Sep 28, 2016 08:01 PM|StrangerMike|LINK
Hello,
I am pulling data from textboxes in my Gridview footer. Some of the fields should be numeric, but when I check for numeric even though there is a numeric value, the code kicks it out as a none numeric, probably because of the quotes surrounding the number like: "12"
How can I convert to numeric to check for numeric value?
Input "12". IsNumeric(newCPM) renders as False.
Member
483 Points
2238 Posts
Re: Inserting from data in Gridview Footer fields
Sep 28, 2016 08:20 PM|StrangerMike|LINK
I think I got it:
Dim CPMNum = Convert.ToInt32(newCPM.Text)
Participant
1060 Points
346 Posts
Re: Inserting from data in Gridview Footer fields
Sep 28, 2016 08:34 PM|Sumit.Pokhriyal|LINK
Please check below code. (Reference: http://stackoverflow.com/questions/13980538/check-if-a-string-variable-has-an-integer-value)
Dim newCPMAsInt As Integer
If Integer.TryParse(newCPM.Text, newCPMAsInt) Then
' newCPM successfully parsed as Integer
Else
' newCPM is not an Integer
End If
/**** Please remember to "Mark as Answer" the responses that resolved your issue. ****/