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

Discussion in 'ASP .Net' started by Anonieko, Apr 8, 2006.

  1. Anonieko

    Anonieko Guest

    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,
     
    Anonieko, Apr 8, 2006
    #1
    1. Advertising

  2. 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 ?

    --
    ( OHM ) - One Handed Man
    AKA Terry Burns - http://TrainingOn.net


    "Anonieko" <> wrote in message
    news:...
    > 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,
    >
     
    OHM \( One Handed Man \), Apr 8, 2006
    #2
    1. Advertising

  3. Anonieko

    Anonieko Guest

    Thanks for the clues.

    The problem is not on the template but on a javascript error in the
    page.
     
    Anonieko, Apr 10, 2006
    #3
  4. Anonieko

    PeterDew

    Joined:
    Jul 6, 2006
    Messages:
    1
    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 "&apos;"

    HTH
     
    PeterDew, Jul 6, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    13,423
  2. Eric Layman
    Replies:
    3
    Views:
    664
    Rad [Visual C# MVP]
    Apr 14, 2007
  3. Evan
    Replies:
    1
    Views:
    419
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
  4. Evan
    Replies:
    3
    Views:
    552
    Marc 'BlackJack' Rintsch
    Nov 4, 2008
  5. vikrant
    Replies:
    8
    Views:
    393
    vikrant
    May 17, 2007
Loading...

Share This Page