Link to home
Start Free TrialLog in
Avatar of p_love
p_love

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of kevincasey
kevincasey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of p_love
p_love

ASKER

Brilliant, thanks.  Any ideas why it works locally but not remotely without this?
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.