简体   繁体   English

从 SQL Server 检索特殊字符的问题

[英]Issue for Retrieving of Special Characters from SQL Server

I display the values into GridView and it displays well.我将这些值显示到 GridView 中,并且显示效果很好。 but when I put a code on OnSelectedIndexChanged with this code:但是当我使用以下代码在OnSelectedIndexChanged上放置代码时:

City = GeneralInfoData.SelectedRow.Cells[13].Text.ToString(); 

and put the value on a textbox.并将值放在文本框上。

The value价值

Dasmariñas

becomes变成

Dasmariñas

它在数据库中保存得很好

If you are seeing that value as part of some HTML in your asp.net application, then there's nothing wrong: ñ如果您在 asp.net 应用程序中看到该值作为某些 HTML 的一部分,那么就没有错: ñ is the HTML code to represent the 'n tilde' character as you can see here: https://www.w3schools.com/charsets/ref_html_8859.asp是表示“n 波浪号”字符的 HTML 代码,如您所见: https : //www.w3schools.com/charsets/ref_html_8859.asp

N with a Tilde comes under ISO-8859-1 encoding.带有波浪号的 N 采用ISO-8859-1编码。

You need to modify your web.config like below:您需要像下面这样修改您的web.config

<system.web> 
<globalization responseEncoding="iso-8859-1" requestEncoding="iso-8859-1" /> 
</system.web> 

Following page will provide an interesting read:以下页面将提供一个有趣的阅读:

https://en.wikipedia.org/wiki/ISO/IEC_8859-1 https://en.wikipedia.org/wiki/ISO/IEC_8859-1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM