Filtering Gridview

  • Thread starter Thread starter Mark B
  • Start date Start date
M

Mark B

This code works fine to filter a Gridview:

With SqlDataSource3
.FilterExpression = "LanguageText LIKE '%{0}%'"
.FilterParameters.Clear()
.FilterParameters.Add("fp2", TextBox4.Text)
End With



unless the text entered in TextBox4.Text includes a single quote '

Then an error is given:

- 'always
Syntax error: Missing operand after 'always' operator.

- alway's
Syntax error: Missing operand after 's' operator.

- always'
The expression contains an invalid string constant: '.


Suggestions?
 
string textBoxValue = TextBox1.Text.Replace("'", "''");

--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*************************************************
| Think outside the box! |
*************************************************
 
Thanks that worked:

With SqlDataSource3
.FilterExpression = "LanguageText LIKE '%{0}%'"
.FilterParameters.Clear()
.FilterParameters.Add("fp2", TextBox4.Text.Replace("'",
"''"))
End With
 
The single quote is the bane of database programmer's existence. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*************************************************
| Think outside the box! |
*************************************************
 
Back
Top