Javascript Error on a GridView templated column where data can contain single quote

A

Anonieko

Hello ASPNET guru's,

What is a clean way to go around the problem of displaying a GridView
templated column where data can contain Single Quote ( ' )?

I maybe too naive, but this is of course a common scenario.

Scenario:

* My database returns names that can contain single quote.
* For example: O'byran, D'Ottwa, Osan's , and so on.
* I use a Gridview to view the data ( ASPNET 2.0 RTM)
* If that GridView column is a Bound Column. NO PROBLEM.
* If you convert that column into a Templated Column, error on
javascript on runtime.


Right now, I just remedy this by going to the database SELECT
statement (or stored proc) and removing the single quote. But what is
the real solution here?

Thanks,
 
O

OHM \( One Handed Man \)

First of all this should not normally be a problem, we do this all the time
with single quotes in template fields and dont experience any javascript
errors.

1.) How and what are you binding your gridview to ?
2.) At what point is the javascript error occuring and what code is failing
( Post it )
3.) Is there any code you are running specific to the textboxes or whatever
controls you are using ?
 
A

Anonieko

Thanks for the clues.

The problem is not on the template but on a javascript error in the
page.
 
Joined
Jul 6, 2006
Messages
1
Reaction score
0
Anonieko,

Do you generate your own javascript code somewhere in the events of the gridview ?
I had a similar problem when showing a special formatted tooltip for each row.
On each row I added an attribute 'onmouseover' and set the tooltip.
There I had to convert all single quotes with the HTML code "'"

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top