+ Reply to Thread
Results 1 to 4 of 4

Thread: Special Characters in DropDownList

  1. #1
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Special Characters in DropDownList

    I have stored special characters in a database (µ) and want to display these in a dropdownlist on a page.

    When I retrieve the records from the db, it is writing the special character as ?? when it should be µ It even does the same if I write it out to the screen.

    Other special characters such as € appear fine when written to the screen.

    I've tried using Server.HTMLEncode in my data access function:-
    Code:
                                while (rs.Read())
                                {
                                    weightList.Add(Convert.ToInt32(rs["id"]), HttpContext.Current.Server.HtmlEncode((string)rs["weight"]));
                                }
    
    where weightList is a Dictionary<int, string> object and HTMLDecode in my page. The weight value from my stored procedure is:-
    Code:
    CONCAT(A.Amount,B.ShortName) AS weight
    
    When I call the sp in Query Browser, the characters appear fine, but I can't get them to appear either in the dropdown or on the screen correctly.

  2. #2
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I've done a workaround of adding another field in my table that has the HTML code ( &micro; ) and using Server.HtmlDecode on this shows the character correctly.

    Would still like to know if there's a way of using the character directly from the db though.

  3. #3
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    You need to look into character encoding. The characters in the database should be saved in the correct format, UTF-8, for example, and the page itself needs to be set and saved at UTF-8.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  4. #4
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I checked on the db and the characterset is utf8.

    The default for a web page would be utf8 also, wouldn't it? I tried including a meta http-equiv statement on the page, but that didn't help either. Not working on it today, so will take another look when I'm next on it.

+ Reply to Thread

Similar Threads

  1. Copy From 1 field to another minus first 2 characters
    By micky in forum SQL Development
    Replies: 2
    Last Post: August 31st, 2009, 08:38 AM
  2. pull by first four characters?
    By Rebelle in forum Microsoft Access
    Replies: 1
    Last Post: June 30th, 2009, 12:36 PM
  3. How do you add a static item to a dynamic dropdownlist
    By Shem in forum .NET Development
    Replies: 19
    Last Post: July 4th, 2008, 09:14 AM
  4. special characters
    By Jaykappy in forum SQL Development
    Replies: 1
    Last Post: May 21st, 2008, 11:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO