Grid.SelectedRow.Cells.Item (1) .Text.ToString returns unencoded characters such as Bol & # 237; vares

I fill the form with data from the selected gridview row in asp.net

TXTName.Text = Grid.SelectedRow.Cells.Item(1).Text.ToString 

Refunds: Bol & # 237; vares Fuertes

 TXTName.Text = Grid.DataKeys(grdMaestro.SelectedRow.RowIndex).Values(1).ToString 

Returns: "Bolívares Fuertes"

the first time letters with accents are displayed as & #XXX, and the second is excellent. The problem with the second method is that I have to include all the rows in the datakeynames attribute, and this can cause some problems if I end up using automatic updating and removing gridview controller functions.

NOTE. I inserted a space between "Bol &" And "# 237; vares Fuertes" because stackoverflow fixed it in the preview

+4
source share
1 answer

Replace it

 TXTName.Text = Grid.SelectedRow.Cells.Item(1).Text.ToString 

with

 TXTName.Text = HttpUtility.HtmlDecode(Grid.SelectedRow.Cells.Item(1).Text.ToString) 

And see if it works now.

Good luck.

+6
source

All Articles