Microsoft KB Archive/317878

= FIX: DataGrid Web Server Control Does Not Display &quot;<&quot; and &quot;>&quot; Characters Correctly =

Article ID: 317878

Article Last Modified on 6/5/2003

-

APPLIES TO


 * Microsoft .NET Framework 1.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer (Programming) 6.0

-



This article was previously published under Q317878



The following Microsoft .NET Framework Class Library namespace is referenced in this article:

System.Data



SYMPTOMS
When you create a Web application that displays data in a DataGrid control, if the data contains the less than character (<) and the greater than character (>), Microsoft Internet Explorer interprets these characters as Hypertext Markup Language (HTML) directives. As a result, the string of data between the &quot;<&quot; and &quot;>&quot; characters in the DataGrid control cannot be displayed.



RESOLUTION
To resolve this problem, change &quot;<&quot; to &quot;&lt;&quot; and &quot;>&quot; to &quot;&gt;&quot;.



STATUS
This bug was corrected in Microsoft .NET Framework 1.0 and in Microsoft Internet Explorer (Programming) 5.01, 5.5, and 6.0.



Steps to Reproduce Behavior
  Create a new file named Repro.aspx, and then add the following code to this file: <%@ Import Namespace=&quot;System.Data&quot; %> 

Dim Cart As DataTable Dim CartView As DataView Function CreateDataSource As ICollection Dim dt As New DataTable Dim dr As DataRow dt.Columns.Add(New DataColumn(&quot;IntegerValue&quot;, GetType(Int32))) dt.Columns.Add(New DataColumn(&quot;StringValue&quot;, GetType(String))) dt.Columns.Add(New DataColumn(&quot;CurrencyValue&quot;, GetType(Double))) Dim i As Integer For i = 0 To 3 dr = dt.NewRow dr(0) = i           dr(1) = &quot;Item &quot; & i.ToString   ' If you use &quot;&quot; instead of &quot;Item&quot;, ' the row is not displayed correctly. dr(2) = 1.23 *(i + 1) dt.Rows.Add(dr) Next i       dr = dt.NewRow dr(0) = 4 dr(1) = &quot; &quot; & 4.ToString  ' The problem occurs here. ' To resolve the problem, comment the preceding ' line, and uncomment the following line. 'dr(1) = &quot; &quot; & 4.ToString dr(2) = 1.23 *(4 + 1) dt.Rows.Add(dr) Dim dv As New DataView(dt) Return dv   End Function 'CreateDataSource

Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then 'Load this data only one time. ItemsGrid.DataSource = CreateDataSource ItemsGrid.DataBind End If   End Sub 'Page_Load

Q317878: DataGrid Web Server Control Does Not Display '<' and '>' Characters Correctly Because you added the &quot;&quot; string in the DataGrid control, the data grid is not displayed correctly. The first four rows in the data grid appear as expected. However, the last row demonstrates the problem. This problem occurs because you include around &quot;Item&quot;. 

 </HeaderStyle>

<FooterStyle BackColor=&quot;#00aaaa&quot;> </FooterStyle> </asp:DataGrid> </li> <li>Open the Repro.aspx file in Internet Explorer. Note that Internet Explorer does not display the fourth row, which contains the &quot;<Item>&quot; string, correctly.</li></ol>

Additional query words: angle brackets

Keywords: kbwebforms kbsystemdata kbdatabinding kbctrl kbprb KB317878

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.