I have the following C# code which populates a dropdownlist:
public void PopulateInsurance()
{
SqlCommand cmd = new SqlCommand("GetInfo", new SqlConnection(ConfigurationManager.AppSettings["connectionstr"]));
cmd.Connection.Open();
SqlDataReader ddles = default(SqlDataReader);
ddles = cmd.ExecuteReader();
ddlI.Items.Clear();
ddlI.DataSource = ddles;
ddlI.DataValueField = "id";
ddlI.DataTextField = "title";
ddlI.DataBind();
//set the default value for the drop down
ListItem Item = new ListItem();
Item.Text = "Any";
Item.Value = "0";
ddlInsurance.Items.Insert(0, Item);
cmd.Connection.Close();
cmd.Connection.Dispose();
}
One of the row in the SQL table has the following values:
id title
9 Worker'
The dropdownlist shows the title as displayed above ('
-> which a single apostrophe'
)
How can I modify the code so it takes the '
or any other special character and unescapes it to show the character, in this example '
.