Gridview nor rendering hyperlinks, just displaying HTML tags

Hello,

I have a GridView and I am processing the values in the first column:  This creates a hyperlink to a new page and passes the value of the link in.  This works fine working locally, but when I upload to my webserver, the first column is rendering as the HTML:

Code

 e.Row.Cells(0).Attributes.Add("onclick", "javascript:void(window.open('Drilldowns/Popup_Window_Milestones_Gantt.aspx?PROJECT_ID=" & DataBinder.Eval(e.Row.DataItem, "PROJECT_ID") & "&PROJECT=" & Server.HtmlEncode(DataBinder.Eval(e.Row.DataItem, "PROJECT")) & "','win',centerTopLeftPos(870,610)));")

Rendering on remote server as:

<span style='text-decoration:underline;cursor:pointer;'>AZD5904 MPO MS</span>


i.e. I am actually seeing <span.... in the gridview.  Funnily enough the hyperlink still works.

Grid view declared:

<asp:GridView ID="grdLevel1MilestonesOverview" runat="server" AllowPaging="true" PageSize="16" Width="950" AutoGenerateColumns="false" Font-Size="6pt" BackColor="#eeeeee">
                                                    <HeaderStyle CssClass="header" />
                                                    <PagerStyle CssClass="footer" />
                                                    <RowStyle CssClass="row" />
                                                    <AlternatingRowStyle CssClass="alternating" />  
                                                    <Columns>                                                        
                                                        <asp:BoundField  DataFormatString="<span style='text-decoration:underline;cursor:pointer;'>{0}</span>"  DataField="PROJECT"  HeaderText="PROJECT" ItemStyle-Wrap="true" >
                                                            <ItemStyle Width="180px"/>
                                                        </asp:BoundField>                                                        
                                                        <asp:BoundField DataField="MS5" HeaderText="MS5"/>
                                                        <asp:BoundField DataField="FGLPD" HeaderText="FGLPD"/>
                                                        <asp:BoundField DataField="TG2" HeaderText="TG2"/>
                                                        <asp:BoundField DataField="FTIM" HeaderText="FTIM"/>
                                                        <asp:BoundField DataField="POP" HeaderText="POP"/>                                                        
                                                        <asp:BoundField DataField="FTIP" HeaderText="FTIP"/>
                                                        <asp:BoundField DataField="TG2.5" HeaderText="TG2.5"/>
                                                        <asp:BoundField DataField="FDIDF" HeaderText="FDIDF"/>
                                                        <asp:BoundField DataField="POC" HeaderText="POC"/>
                                                        <asp:BoundField DataField="TG3" HeaderText="TG3"/>
                                                        <asp:BoundField DataField="TG4" HeaderText="TG4"/>
                                                        <asp:BoundField DataField="MS8" HeaderText="MS8"/>
                                                        <asp:BoundField DataField="MS9" HeaderText="MS9"/>
                                                    </Columns>      
                                                    </asp:GridView>  




Protected Sub grdLevel1MilestonesOverview_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdLevel1MilestonesOverview.RowDataBound
 
        ' We need to catch these events as the data is bound to the grid view so we can
        ' control for formatting of the dates, and so we can create hyperlinks from
        ' the project name to the study level gantt chart
 
        If e.Row.RowType = DataControlRowType.DataRow Then
            If IsDate(e.Row.Cells(1).Text.Trim) = True Then
                e.Row.Cells(1).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(1).Text))
 
            End If
 
            If IsDate(e.Row.Cells(2).Text.Trim) = True Then
                e.Row.Cells(2).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(2).Text))
 
            End If
 
            If IsDate(e.Row.Cells(3).Text.Trim) = True Then
                e.Row.Cells(3).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(3).Text))
 
            End If
 
            If IsDate(e.Row.Cells(4).Text.Trim) = True Then
                e.Row.Cells(4).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(4).Text))
 
            End If
 
            If IsDate(e.Row.Cells(5).Text.Trim) = True Then
                e.Row.Cells(5).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(5).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(6).Text.Trim) = True Then
                e.Row.Cells(6).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(6).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(7).Text.Trim) = True Then
                e.Row.Cells(7).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(7).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(8).Text.Trim) = True Then
                e.Row.Cells(8).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(8).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(9).Text.Trim) = True Then
                e.Row.Cells(9).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(9).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(10).Text.Trim) = True Then
                e.Row.Cells(10).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(10).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(11).Text.Trim) = True Then
                e.Row.Cells(11).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(11).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(12).Text.Trim) = True Then
                e.Row.Cells(12).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(12).Text))
 
            End If
 
 
            If IsDate(e.Row.Cells(13).Text.Trim) = True Then
                e.Row.Cells(13).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(13).Text))
 
            End If
 
            ' Add the drill down capability to the first column (project) to allow us to pass the project name
            ' into a separate web page to study the level 1/ level 2 combined gantt chart
            e.Row.Cells(0).Attributes.Add("onclick", "javascript:void(window.open('Drilldowns/Popup_Window_Milestones_Gantt.aspx?PROJECT_ID=" & DataBinder.Eval(e.Row.DataItem, "PROJECT_ID") & "&PROJECT=" & Server.HtmlEncode(DataBinder.Eval(e.Row.DataItem, "PROJECT")) & "','win',centerTopLeftPos(870,610)));")
 
 
        End If
 
    End Sub

Open in new window

LVL 1
p_loveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kevincaseyCommented:
Have you tried turning the HTML Encoding off for that column?
<asp:GridView ID="grdLevel1MilestonesOverview" runat="server" AllowPaging="true" PageSize="16" Width="950" AutoGenerateColumns="false" Font-Size="6pt" BackColor="#eeeeee">
  <HeaderStyle CssClass="header" />
  <PagerStyle CssClass="footer" />
  <RowStyle CssClass="row" />
  <AlternatingRowStyle CssClass="alternating" />   
  <Columns>                                                        
    <asp:BoundField  DataFormatString="<span style='text-decoration:underline;cursor:pointer;'>{0}</span>"  DataField="PROJECT"  HeaderText="PROJECT" ItemStyle-Wrap="true" HtmlEncode="false">
      <ItemStyle Width="180px"/>
    </asp:BoundField>
    <asp:BoundField DataField="MS5" HeaderText="MS5"/>
    <asp:BoundField DataField="FGLPD" HeaderText="FGLPD"/>
    <asp:BoundField DataField="TG2" HeaderText="TG2"/>
    <asp:BoundField DataField="FTIM" HeaderText="FTIM"/>
    <asp:BoundField DataField="POP" HeaderText="POP"/>
    <asp:BoundField DataField="FTIP" HeaderText="FTIP"/>
    <asp:BoundField DataField="TG2.5" HeaderText="TG2.5"/>
    <asp:BoundField DataField="FDIDF" HeaderText="FDIDF"/>
    <asp:BoundField DataField="POC" HeaderText="POC"/>
    <asp:BoundField DataField="TG3" HeaderText="TG3"/>
    <asp:BoundField DataField="TG4" HeaderText="TG4"/>
    <asp:BoundField DataField="MS8" HeaderText="MS8"/>
    <asp:BoundField DataField="MS9" HeaderText="MS9"/>
  </Columns>       
</asp:GridView>  

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
p_loveAuthor Commented:
Brilliant, thanks.  Any ideas why it works locally but not remotely without this?
0
kevincaseyCommented:
Perhaps some sort of default setting on the local machine, or an XP vs. Server thing...  I run into that particularly when trying to determine the logged on user.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.