c# -
用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(" ", match.Length)));
或在标记代码中
<EditItemTemplate>
<asp:TextBox ID="txcontents" runat="server"
Text='<%# Server.HtmlDecode(Eval("contents").ToString().Replace("<br />", " ")) %>'
TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
但这行不通。
有人可以帮忙吗?
解决方案
推荐阅读
- c# - 在同一个应用服务中托管多个不相关的 API
- azure - Azure ARM 模板 - vnet 示例
- go - 无法从 Google 获取访问令牌
- java - Catch() 不捕获异常
- flask - 雪花 OAuth 烧瓶
- asp.net-mvc - 在 Razor View 的@html.ActionLink 中,我们如何传递下拉列表的值?
- javascript - 循环开始时,我的函数不会重新触发动画。红绿灯闪烁信号一次工作
- android-layout - 内部空心形状矩形可绘制/画布形状
- html - Bootstrap - 在页面顶部放置导航栏,然后将表单居中
- java - java spring boot oracle cdc debezium