Simple if-then error in onClick

  • Thread starter Thread starter DC Gringo
  • Start date Start date
D

DC Gringo

I'm getting the following error when running and if-then upon submitting a
dropdownlist value. HELP?!

Exception Details: System.FormatException: Input string was not in a correct
format.

Sub RunReport_OnClick(sender As Object, e As System.EventArgs)

If ddlCommunities.SelectedItem.Value <> 0 Then
_sqlStmt = _sqlStmt & " AND tblSurvey1.clnGUID =
'"+ddlCommunities.SelectedItem.Value+"'"
End if

BindData()
End Sub
 
I think there's a bit of a mix-up in your string concatenation syntax
between SQL and VB. See if this example works:

If ddlCommunities.SelectedItem.Value <> 0 Then
_sqlStmt &= " AND tblSurvey1.clnGUID = '" &
ddlCommunities.SelectedItem.Value & "'"
End if
 
Back
Top