I am new to C# and was experimenting with the ASP.Net GridView (framework 3.5), and I found out a big problem when the gridView text contains the following:
ñ/Ñ/á/Á/é/É/í/Í/ó/Ó/ú/Ú or a â, ê, î, ô, û, ë, ï, ü or even a ç
The results end up displaying something like this: &+#+237
I made a mixture of pain by doing a table,dataset etc... to get the data from the database clean as the letter itself. I also tried making a method that cleaned the variables but it was a terrible IF.
I was wondering if there was a way to make the letters appear as themselves (ñ as ñ not as &+#+237) when extracting data from the gridview without getting the data directly from the database and without doing a lot of code. If there is not, is there a way to code efficiently clean them up?
Your characters are being HTML encoded, either somewhere in your data access layer, or within the gridview controls. Try running the text through
HttpUtility.HtmlDecode()
before binding the grid.If that doesn't work, then it's probably being encoded at the control level. I see that you tagged this question with "textbox". The standard ASP.NET TextBox control will automatically encode anything that's assigned to its Text property. Instead, you can use a generic
System.Web.UI.HtmlControls.HtmlTextArea
control ornew HtmlGenericControl("input")
.