Question

I have a database with MCQ which i query and fill a datatable with. My problem is with displaying. I'm using this

Rbloptions.Items.Insert(0, new ListItem(dt.Rows[RowNo]["Distractor1"].ToString(), dt.Rows[RowNo]["Distractor1"].ToString()));

If the value is mark up for example, i get all sorts of craziness e.g. the value is not displayed, parts of the words in the value are displayed etc. How can i ensure that the radio button item uses the literal value.

Environment: VS 2012 C# asp.net 4.5

Was it helpful?

Solution

Consider doing this to get those values in there:

var val = HttpServerUtility.HtmlEncode(dt.Rows[RowNo]["Distractor1"].ToString());
Rbloptions.Items.Insert(0, new ListItem(val, val));

That will encode those values before setting them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top