我怎样才能在ASP.Net的GridView显示与回车文本 [英] How can I display text with carriage returns in a GridView in ASP.Net

查看:110
本文介绍了我怎样才能在ASP.Net的GridView显示与回车文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示我的GridView中的记录和少数细胞含有与回车文本。然而,当显示回车此文本的回报都没有了。有没有一种简单的方法在GridView单元格中显示回车?

I'm trying to display records within my GridView and a few of the cells contain text with carriage returns. However when this text is displayed the carriage returns are gone. Is there an easy way to display carriage returns in a GridView Cell?

我一直使用的作品细胞内的文本框尝试,但后来我有TextBox的scollbars。我不是太热衷于这种方式,无论是作为文本框可以在不同的浏览器中呈现不同的。

I've tried using a TextBox within the cell which works but I then have the scollbars of the TextBox. I'm not too keen on this way either as the textbox may render differently in different browser.

我的code显示如下,我已经离开我的测试在那里,所以你可以看到我已经尝试了所有方式:

My code is displayed below, I've left my testing in there so you can see all the ways I've tried:

<asp:GridView ID="gridResults" runat="server"  AutoGenerateColumns="false" CellSpacing="-1" 
            CssClass ="stretch separate" GridLines="None" EnableViewState="true">
            <HeaderStyle CssClass="header pad" />
            <RowStyle CssClass="row pad"/>                
            <EmptyDataRowStyle CssClass="empty pad" />
            <Columns>
                <asp:BoundField DataField="Notes" HeaderText="Notes"  HtmlEncode="true">
                    <ItemStyle Width="100"   />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Notes" >
                    <ItemTemplate>
                        <asp:Label ID="test" runat="server"   Text='<%# Bind("Notes") %>' />
                        <asp:TextBox ID="textNotes" runat="server" CssClass="right"  TextMode="MultiLine" Text='<%# Bind("Notes") %>' BorderStyle="None" />
                    </ItemTemplate>                        
                    <ItemStyle Width="50" CssClass="right"  />
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

我使用ASP.Net 4.0和C#

I'm using ASP.Net 4.0 and c#

感谢

推荐答案

尝试设置了文本&LT的属性; ASP:标签&gt; 文本='&LT;%#的eval(票据)的ToString()替换(\\ n,&LT; BR /&gt;中)。%GT;

这篇关于我怎样才能在ASP.Net的GridView显示与回车文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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