【问题标题】:Dropdown list with white spaces带有空格的下拉列表
【发布时间】:2013-10-27 10:05:28
【问题描述】:

我有一个这样绑定的下拉列表。

 string qissuetype = "select trim(empname),empfullname from empmast where " + ListBox1.SelectedValue + "<3 order by empname";
 OdbcDataAdapter adpState = new OdbcDataAdapter(qissuetype, con1);
 DataSet ds = new DataSet();
 adpState.Fill(ds);                
 drpResponsible.DataSource = ds;
 drpResponsible.DataTextField = "trim(empname)";
 drpResponsible.DataValueField = "empfullname";
 drpResponsible.DataBind();

我在绑定时修剪了 empname,但它仍然显示前导和尾随空格(如果存在)。

谁能帮我做这件事? 提前致谢

【问题讨论】:

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


    【解决方案1】:

    如果不支持TRIM(),则LTRIM(RTRIM(empname)) 将获得相同的结果。

    另外,你可以试试这些链接:

    1) Remove Trailing Spaces and Update in Columns in SQL Server

    2) How to remove white space characters from a string in SQL Server

    3)Remove all spaces from a string in SQL Server

    希望您能得到解决方案,谢谢...

    【讨论】:

      【解决方案2】:

      不幸的是,sql 有时会保留各种难以删除的特殊字符。在这里Removing White Space: C#尝试使用正则表达式的解决方案。

      另外,如果您使用的是另一种语言,例如我使用的是希伯来语,有时即使这样还不够,正则表达式需要使用 [a-zA-Z] 和您的 lang 字母。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-06
        • 2015-10-25
        • 1970-01-01
        相关资源
        最近更新 更多