I'm writing a small page to show the employees in our company. I've written a query to pull the info from our database. Then I'm binding that to a GridView to do the dirty work. Here is the query.
"SELECT tblEmpID.empid AS [Empl ID], tblEmpID.posno AS [Pos #], [name] & ""<br />"" & [jcn] & ""("" & [jcc] & "")"" AS [Name/Job], [orgno] & "" - "" & [depname] AS Department, tblEmpID.[status] AS Status " & _
"FROM tblEmpID " & _
"ORDER BY [orgno] & "" - "" & [depname], tblEmpID.name "
As you can see, I'm trying to include a
inside the SQL so when it renders it will look like:
Name
Job Description
But when it renders it renders as
< and >
Effectively showing the <br /> in the record instead of formatting it like I want.
So how to I make it render like I want? I've already tried escaping the < with \ and that did not work.
EDIT: Thanks gfrizzle. Your answer set me down the right path. Also, thank you NYSystemsAnalyst. Your answer helped me think of a different way to do things in the future. Ultimately, I found a different solution. I put this code in the GridView1_RowDataBound event and it does what I need.
If e.Row.RowType = DataControlRowType.DataRow Then
Dim cells As TableCellCollection = e.Row.Cells
For Each cell As TableCell In cells
cell.Text = Server.HtmlDecode(cell.Text)
Next
End If