首页 > 解决方案 >
用C# 中编辑 grdiview 中不起作用的空格替换每个字符串

问题描述

我已将此字符串存储在数据库中

mystreet mycity mytown

在 griview 中编辑行时,我在TextBox中有这样的字符串

mystreet<br />mycity<br />mytown

我想要做的是替换<br />space

我在数据库中尝试过:

REPLACE(mystring,'\r' OR '\n' OR '\r\n', ' ')

我在代码隐藏中尝试过:

string newTextcontents = txtcontents.Text.ToString().Replace("'", "`").Replace("<br />", " ");

或者

string newTextcontents = txtcontents.Text.ToString().Replace("'", "`");

string result = Regex.Replace(newTextcontents, @"(?<=\<br \/\>)\s+",
    match => string.Concat(Enumerable.Repeat("&nbsp;", match.Length)));

或在标记代码中

<EditItemTemplate>
    <asp:TextBox ID="txcontents" runat="server"
        Text='<%# Server.HtmlDecode(Eval("contents").ToString().Replace("<br />", " ")) %>'
        TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>

但这行不通。

有人可以帮忙吗?

标签: c#mysqlgridview

解决方案


推荐阅读