简体   繁体   中英

Xml formatted data to gridview asp.net C#

I have xml file with description element, descriptions are long, how can I display them as formatted text in gridview. I tried adding <br/> tags in description, but asp.net page is not displaying them.

I have a structure name FileItems and in that description string, so I save data from xml to this,

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

On .aspx side I am using below code to display:

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

a sample text in xml file,

<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>

Solved it using setting HtmlEncode="false" in BoundField. Also added in xml file. If there is any other way to solve it then i would like to know, i think we can also use htmldecode of httputility.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM