【问题标题】:Xml formatted data to gridview asp.net C#Xml 格式化数据到 gridview asp.net C#
【发布时间】:2016-10-10 12:59:54
【问题描述】:

我有带有描述元素的 xml 文件,描述很长,如何在 gridview 中将它们显示为格式化文本。我尝试在描述中添加<br/>标签,但asp.net页面没有显示它们。

我有一个结构名称 FileItems 并且在那个描述字符串中,所以我将数据从 xml 保存到这个,

FileItems.AppDescription = xmlNode.ChildNodes[i].InnerText;

在 .aspx 端我使用下面的代码来显示:

<asp:BoundField DataField="AppDescription" HeaderText="AppDescription" 
        SortExpression="AppDescription">
        <ItemStyle Width="55%"></ItemStyle>
    </asp:BoundField>

xml 文件中的示例文本,

<description>
1. Lorem Ipsum is simply dummy text of the printing and typesetting industry.
2. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.
3. When an unknown printer took a galley of type and scrambled it to make a type specimen book.
4. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
</description>

【问题讨论】:

    标签: c# asp.net xml gridview


    【解决方案1】:

    通过在 BoundField 中设置 HtmlEncode="false" 解决了这个问题。还添加到 xml 文件中。如果有任何其他方法可以解决它,那么我想知道,我认为我们也可以使用 httputility 的 htmldecode。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-20
      • 2010-09-11
      • 2012-02-01
      • 2013-10-02
      • 1970-01-01
      • 2011-04-15
      • 1970-01-01
      相关资源
      最近更新 更多