Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDownList being html encoded 1

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
IE
MyDropDown = System.Web.UI.WebControls.DropDownList
MyReader = System.Web.UI.WebControls.SqlDataReader

MyDropDown.Items.Add(New ListItem(MyReader("Value1"), MyReader("Value2")))

I have a dropdownlist that I want to add values to. The problem is that
the values in question have HTML in them. So in this example MyReader("Value1")
will have values like  a and then   b etc

Instead of getting a dropdownlist as follows

<select>
<option value="a">&nbsp;a</option>
<option value="b">&nbsp;&nbsp;b</option>
</select>


I end up getting

<select>
<option value="a">&amp;nbsp;a</option>
<option value="b">&amp;nbsp;&amp;nbsp;b</option>
</select>


as it html encodes the '&' on the fly which will renders
my nbsp null and void.

How do you prevent this HTML encoding going on?
 
Why does this matter? As far as the user will see, it should display correctly and if you need to read it, you can use the Server.HTMLDecode function to get the correct value.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
It wasn't displaying correctly, &amp;nbsp;a will be displayed as is - Server.HTMLDecode sorted it, cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top