用新行绑定数据 [英] binding data with new line

查看:77
本文介绍了用新行绑定数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中我有一个textarea,其中保存数据我已设法用新行保存数据但在标签中绑定数据我想显示它插入

表示如果我我保存的数据如

a 1

b 2

c 3

它应该以类似方式绑定但目前是绑定比如1 b 2 c 3

我的代码是

in my project i have a textarea in which while saving data i have managed to save data with new line but while binding data in label i want to show it as it was inserted
means if i am saving data like
a 1
b 2
c 3
it should be bind in similar way but currently is binding like a 1 b 2 c 3
my code is

tenderDetail.ExtraInfo = Server.HtmlEncode(txtExtraInfo.Text);


lbExtraInfo.Text = /*divExtraInfo.InnerHtml =*/ Server.HtmlDecode(tenderDetail.ExtraInfo.ToString());


<%--     <div  runat="server" id="divExtraInfo">--%>

                </div>
                <asp:Label ID="lbExtraInfo" runat="server" Width="260px" Height="100px" Text='<%# "ID: " +Eval("ExtraInfo").ToString() %>'
                    CssClass="label-size"></asp:Label>

推荐答案

您好,



尝试使用 pre 标签或用< br>替换CrLf输出中的标记。

Hello,

Either try using pre tag or replace CrLf with <br> tag in output.
<asp:Label ID="lbExtraInfo" runat="server" Width="260px" Height="100px" 

    Text='<%# "ID: "  + Regex.Replace(Eval("ExtraInfo").ToString(), "\r\n|\r|\n", "<br>") %>' 

    CssClass="label-size"></asp:Label>



问候,


Regards,


这篇关于用新行绑定数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆