Not Encode & to &

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a stored procedure that returns 2 columns named Title & URL. Some
sample data are:

Title URL
==== ====
C# Tutorial index.aspx?sectionID=2&id=9
SQL Help index.aspx?sectionID=3&id=1

My page returns a dataset "DsPageList" from this stored procedure and I bind
the data to a DropDownList "PageList". This DropDownList is a jump menu that
will bring the user to the URL. Here's the code for the binding.

PageList.DataSource = DsPageList;
PageList.DataTextField = "Title";
PageList.DataValueField = "URL";
PageList.DataBind();

However, when the page is rendered, the drop menu becomes:

<select name="PageList" onchange="__doPostBack('PageList','')"
language="javascript" id="PageList">
<option value="index.aspx?sectionID=2&id=9">C# Tutorial</option>
<option value="index.aspx?sectionID=3&id=1">SQL Help</option>
</select>

Now the drop menu doesn't work 'cuz the "&" has been encoded to "&amp;". Is
there any way I can "escape" this ecoding?

Thanks.
 
It is correct that the drop-down control will automatically HTML encode all
values. However, when retrieving the selected value on postback, the value
contained in DropDownList.SelectedValue will be correctly decoded so you
should not be having any problems in your code behind.

Regards, Jakob.
 
Back
Top