Hi. I have a test program written in VS 2005 with a DataGrid in it. The records are fetched from the database but I have a weird problem. The grid does not display the data if it starts with a Less Than symbol '<'. All it shows is a white space. When I check it on VS Visualizer, the data is being fetched correctly with the Less Than symbol.

The reason why I used a DataGrid instead of GridView is because the real application that I'm trying to fix was originally from VS2003 and just migrated to VS2005.

Here is my sample code:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class frmGrid : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)

    private void BindData()
        DatabaseConnection db = new DatabaseConnection();
        GridView1.DataSource = db.GetAllClients();

    protected void GridView1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
        GridView1.CurrentPageIndex = e.NewPageIndex;

I'd suspect it has something to do with the fact that < is the start of an HTML statement. Try convert it to &lt;

have you tried converting it to a string when it is fetched from the DB and just treating it as a string until your putting it back in the DB or is that not possible in this case ?

Edited 4 Years Ago by ChrisHunter: n/a

This article has been dead for over six months. Start a new discussion instead.