Asp.Net DropDownList有叛逆者的问题

时间:2011-05-20 15:46:07

标签: c# .net asp.net html drop-down-menu

我正在使用以下代码

向DropDownList添加记录
this.ddlLocation.Items.Add(new ListItem(hs.ToString(), ll.id));

这适用于普通字符串但是如果字符串中有撇号,它会以html格式显示为

<option value="11">Queen&amp;amp;apos;s University</option>

应该是女王大学。我在传递字符串之前立即检查了它的值,它应该如何。它看起来像是被编码两次所以原始的选区被取出后跟着&符号退出字符。我不确定编码在哪里以及如何错过其中一个编码。

我也在使用.Net 4.0

由于

为下拉列表添加了完整的html。

<div class="fieldCol">
                            <label for="peopleSearch_lawSchool">LawSchool</label>
                            <select name="ctl00$nrContentPlaceHolder$ddlLawSchool" id="nrContentPlaceHolder_ddlLawSchool" class="peopleSearch_lawSchool" name="peopleSearch_lawSchool">
    <option value="0">All</option>
    <option value="1">Boston University</option>
    <option value="2">Columbia University</option>
    <option value="3">Cornell Law School</option>
    <option value="4">Dalhousie University</option>
    <option value="5">HEC Montr&#233;al</option>
    <option value="6">London School of Economics and Political Science</option>
    <option value="7">Loyola University</option>
    <option value="8">Magdalene College - Cambridge</option>
    <option value="9">McGill University</option>
    <option value="10">Osgoode Hall Law School</option>
    <option value="11">Queen&amp;amp;apos;s University</option>
    <option value="12">Symbiosis Law College</option>
    <option value="13">Universit&#233; de Moncton</option>
    <option value="14">Universit&#233; de Montr&#233;al</option>
    <option value="15">Universit&#233; de Sherbrooke</option>
    <option value="16">Universit&#233; du Qu&#233;bec &#224; Montr&#233;al</option>
    <option value="17">Universit&#233; Laval</option>
    <option value="18">Universit&#233; Paris X</option>
    <option value="19">University of Alberta</option>
    <option value="20">University of Birmingham</option>
    <option value="21">University of British Columbia</option>
    <option value="22">University of Bucharest</option>
    <option value="23">University of Calgary</option>
    <option value="24">University of California</option>
    <option value="25">University of Cambridge</option>
    <option value="26">University of Detroit Mercy School of Law</option>
    <option value="27">University of Glasgow</option>
    <option value="28">University of London</option>
    <option value="29">University of London, England</option>
    <option value="30">University of Manitoba</option>
    <option value="31">University of New Brunswick</option>
    <option value="32">University of Ottawa</option>
    <option value="33">University of Oxford</option>
    <option value="34">University of Pennsylvania</option>
    <option value="35">University of Pune</option>
    <option value="36">University of Toronto</option>
    <option value="37">University of Victoria</option>
    <option value="38">University of Western Ontario</option>
    <option value="39">University of Windsor</option>

</select>
                        </div>

它使用的是asp:dropdownlist

1 个答案:

答案 0 :(得分:1)

我不确定您是否可以在DropDownList中抑制编码,因此我建议您查看hs编码的位置,看看是否可以解决此问题。