0

When I set textbox.Text with data contains apostrophe from a gridviewrow, it change the apostrophe to &#39. For example, the data in my database showing 40' and it shows 40&#39 instead when I assign to the textbox. How do I decode it? Thanks for any help. Here is my code.

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridViewRow row = GridView1.SelectedRow;

    textbox.Text = row.Cells[1].Text;
}
4

1 回答 1

2

您可以使用HttpUtility类中的 HtmlDecode。

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridViewRow row = GridView1.SelectedRow;

    textbox.Text = HttpUtility.HtmlDecode(row.Cells[1].Text);
}
于 2013-01-11T19:45:40.830 回答