문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top