Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html dropdownlist中丢失的空格字符_Html_Asp.net_Sql Server 2008_Drop Down Menu_Spaces - Fatal编程技术网

Html dropdownlist中丢失的空格字符

Html dropdownlist中丢失的空格字符,html,asp.net,sql-server-2008,drop-down-menu,spaces,Html,Asp.net,Sql Server 2008,Drop Down Menu,Spaces,我有从SQL数据库生成的值的下拉列表 这是我的下拉列表: <asp:DropDownList ID="dropProb" AppendDataBoundItems="true" EnableViewState="false" runat="server" DataSourceID="Prob" DataTextField="val" DataValueField="Value2"> <Items> <asp:ListI

我有从SQL数据库生成的值的下拉列表

这是我的下拉列表:

<asp:DropDownList ID="dropProb" AppendDataBoundItems="true" EnableViewState="false"
      runat="server" DataSourceID="Prob" DataTextField="val" DataValueField="Value2">
       <Items>
           <asp:ListItem Text="None" Value=""></asp:ListItem>
        </Items>
</asp:DropDownList>
<asp:SqlDataSource ID="Prob" runat="server" ConnectionString="<%$ConnectionStrings:DispatchConnectionString %>"
SelectCommand="SELECT (rtrim(value2) + space(15 - len(value2)) + Value3) as val,Value2 FROM [Parameter] WHERE ([ParamType] = @ParamType) ">
<SelectParameters>
   <asp:Parameter DefaultValue="PROB" Name="ParamType" Type="String" />
     </SelectParameters>
</asp:SqlDataSource>
要获取要在下拉列表上显示的值,根据我的查询,它应该有空间

但不幸的是,它没有显示空间,以下是图片:

但如果我运行Sql查询,它会给出我想要的结果:


我的下拉列表代码有问题吗?或者无法显示空格字符?

必须将空格替换为&nbps;为了让html正确呈现您的空间

    SELECT REPLACE(
    (rtrim(value2) + space(15 - len(value2)) + Value3),
    ' ',
    '&nbsp;'
    ) as val,
    Value2
    FROM [Parameter]
    WHERE ([ParamType] = @ParamType) 

必须将空格替换为&nbps;为了让html正确呈现您的空间

    SELECT REPLACE(
    (rtrim(value2) + space(15 - len(value2)) + Value3),
    ' ',
    '&nbsp;'
    ) as val,
    Value2
    FROM [Parameter]
    WHERE ([ParamType] = @ParamType) 

我想把空格betweiin这个值(rtrim(value2)+空格(15-len(value2))+Value3)作为val,但是这个空格没有显示在我的下拉列表上?也许把“+”(literallyspace)“+”放在你的两个值之间可以解决这个问题?起初我试着把空格放在我的值中,但仍然没有显示..我想把空格betweiin这个值(rtrim)(value2)+空格(15-len(value2))+Value3)作为val,但空格没有显示在我的下拉列表中?可能会放“+”(literallyspace)+”在你的两个值之间可以解决这个问题吗?起初我试图在我的值中加入“空格”,但仍然没有出现..啊,从来没有想过要将
'
替换为
'
啊,从来没有想过要将
'
替换为
'